From bc46d9dcab2b4ec0effc296ce13c017ffd4b37ca Mon Sep 17 00:00:00 2001 From: noctuid Date: Tue, 18 Jul 2017 20:14:24 +0900 Subject: [PATCH] Add check to ensure a valid program --- README.org | 2 +- tdrop | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 77c468a..c1aa437 100644 --- a/README.org +++ b/README.org @@ -38,7 +38,7 @@ alt + s tdrop -ma -w -4 -y "$PANEL_HEIGHT" -s dropdown termite #+END_EXAMPLE -The positional argument +The positional argument should be the name of a program in =$PATH= (as opposed to the full path to a program) and should not contain any flags (see =-f= if you want to pass additional flags to the program when running it). ** Basic Flags =-s= / =--session= should only be used for supported terminals and if the user wants to start a tmux or tmuxinator session. =-a= / =--auto-detect-wm= should be used to automatically set certain options (=-l=, =-L=, =-d=, and/or =-i=) based on the current window manager. These flags (whether automatically or manually set) may be necessary for tdrop to behave correctly (e.g. they are required for =-w= / =--width=, =-h= / =--height=, =-x= / =--xoff=, and =-y= / =--yoff= to work correctly on tiling window managers). See the manpage for these flags for specific details. diff --git a/tdrop b/tdrop index 09e3fc0..0fe2c01 100755 --- a/tdrop +++ b/tdrop @@ -161,6 +161,13 @@ done shift "$((OPTIND-1))" program=$1 +# check that the program is not a path and does not contain flags +if ! type "$program" 2> /dev/null; then + echo >&2 "The program should be in PATH and not contain flags." | \ + tee -a "$MUTDROP_PATH"/log + exit 1 +fi + if [[ $# -ne 1 ]]; then echo >&2 "Exactly 1 positional argument is required." \ "For help use -h or --help or see the manpage." | \