From 34d17d1e9902f177c3324ba05a08abf5ce56c713 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 3 Nov 2024 01:52:52 +0000 Subject: [PATCH] Run programs with "setsid" --- q-run | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/q-run b/q-run index 7cd87e2..e94e6d4 100755 --- a/q-run +++ b/q-run @@ -5,23 +5,22 @@ ENV_sort=sort ENV_uniq=uniq find_all_executables() { - { - IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done; - } | $ENV_sort | $ENV_uniq + { + IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done; + } | $ENV_sort | $ENV_uniq } if [[ -z "$@" ]]; then - echo "^run [a-zA-Z0-9_-]*$" + echo "^run [a-zA-Z0-9_-]*$" elif [[ "$1" == "--hint" ]]; then - find_all_executables | $ENV_awk '{print $1 " run " $1}' + find_all_executables | $ENV_awk '{print $1 " run " $1}' elif [[ "$1" == "--complete" ]]; then - shift - find_all_executables | $ENV_awk '{print $1 " run " $1}' + shift + find_all_executables | $ENV_awk '{print $1 " run " $1}' elif [[ "$1" == "--preview" ]]; then - shift - echo "Will run $1" + shift + echo "Will run $1" elif [[ "$1" == "--run" ]]; then - shift - (nohup "$1" 2>/dev/null &) - sleep 0.01 + shift + setsid "$1" fi