diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/br | 4 | ||||
-rwxr-xr-x | scripts/nsend | 2 | ||||
-rwxr-xr-x | scripts/sdev | 8 | ||||
-rwxr-xr-x | scripts/slib | 7 |
4 files changed, 12 insertions, 9 deletions
@@ -33,8 +33,8 @@ if [ "${#}" -eq 0 ]; then [ -z "${link}" ] || "${browser}" "${link}" -elif [ "${#}" -eq 1 ]; then - [ "${1}" = "-h" ] && help +elif [ "${#}" -eq 1 ]; then + [ "${1}" = "-h" ] && help "${browser}" "${1}" else diff --git a/scripts/nsend b/scripts/nsend index 7337b4d..5aef4fd 100755 --- a/scripts/nsend +++ b/scripts/nsend @@ -21,7 +21,7 @@ case "${1}" in "-s") [ "${#}" -gt 3 ] && invalid_use - run "notify-send ${2} ${3}" + echo $(printf 'notify-send "%s" "%s"' "${1}" "${2}") exit 0 ;; diff --git a/scripts/sdev b/scripts/sdev index 22c1af5..39f22c5 100755 --- a/scripts/sdev +++ b/scripts/sdev @@ -50,13 +50,13 @@ check_program "xinput" while getopts "e:d:t:lh" option; do case "${option}" in - e) + e) get_id "${OPTARG}" xenable "${id}" ;; - d) + d) get_id "${OPTARG}" - xdisable "${id}" + xdisable "${id}" ;; t) get_id "${OPTARG}" @@ -67,7 +67,7 @@ while getopts "e:d:t:lh" option; do l) if ! xinput list 2>/dev/null; then err "Listing Failed" - else + else exit 0 fi ;; diff --git a/scripts/slib b/scripts/slib index 30e32ca..5ea05d6 100755 --- a/scripts/slib +++ b/scripts/slib @@ -15,7 +15,6 @@ argv0=$(basename "${0}") # @EXAMPLE: # err "Invalid usage" "Try '${argv0} -h' for help." - err() { if [ "${1}" != "-x" ]; then printf "%s: " "${argv0}" @@ -32,7 +31,7 @@ err() { # @FUNCTION: invalid_use # USAGE: [-h] # @DESCRIPTION: -# Output a usage error message. If `-h` is not specified output: +# Output a usage error message. If `-h` is not specified output: # "<program>: Invalid usage " # "Try 'program -h' for help." # else output only: @@ -72,6 +71,10 @@ check_program() { # To add a failure message a success message must also be present. # The output of the command is not suppressed. # +# This implementation does **not** use `eval`. Only simple commands and arguments are supported. +# Shell control operators like `&&`, `||`, pipes (`|`), or redirection (`>`, `>>`, etc.) will not work. +# This prevents unintended execution and makes it safe for use in scripts. +# # @EXAMPLE: # Run xwallpaper command if success print out ${image}: # |