From bd017bfadeaff71f34dbb38b1eac322ef52b7483 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 15 Oct 2016 01:12:31 +0300 Subject: [PATCH] Create tmp dir in advance; set trap to remove it --- ls-not-pushed-carefully | 11 ++++++----- ls-status-carefully | 11 ++++++----- status-dirty-carefully | 13 +++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ls-not-pushed-carefully b/ls-not-pushed-carefully index 0ae1935..266e4ca 100755 --- a/ls-not-pushed-carefully +++ b/ls-not-pushed-carefully @@ -1,13 +1,14 @@ #! /bin/sh +LSTMP="$HOME"/tmp/ls-not-pushed-carefully.tmp +export LSTMP +trap 'exec rm -rf "$LSTMP"' 0 HUP INT QUIT TERM + cd "`dirname \"$0\"`" && prog_dir="`pwd`" && -cd "$HOME"/tmp && rm -rf ls-not-pushed-carefully.tmp && +rm -rf "$LSTMP" && mkdir "$LSTMP" && -LSTMP="$HOME"/tmp/ls-not-pushed-carefully.tmp \ "$prog_dir"/do-all \ 'test "$g" = "$d/.git" || continue;' \ 'rsync -aW --del --protocol=28 "$d" "$LSTMP" && cd "$LSTMP/$b" &&' \ 'test -n "`git status --branch --short | grep "ahead\|behind"`" && - echo "$d"' && - -cd "$HOME"/tmp && exec rm -rf ls-not-pushed-carefully.tmp + echo "$d"' diff --git a/ls-status-carefully b/ls-status-carefully index eca5999..cecdfa4 100755 --- a/ls-status-carefully +++ b/ls-status-carefully @@ -1,12 +1,13 @@ #! /bin/sh +LSTMP="$HOME"/tmp/ls-status-carefully.tmp +export LSTMP +trap 'exec rm -rf "$LSTMP"' 0 HUP INT QUIT TERM + cd "`dirname \"$0\"`" && prog_dir="`pwd`" && -cd "$HOME"/tmp && rm -rf ls-status-carefully.tmp && +rm -rf "$LSTMP" && mkdir "$LSTMP" && -LSTMP="$HOME"/tmp/ls-status-carefully.tmp \ "$prog_dir"/do-all \ 'test "$g" = "$d/.git" || continue;' \ 'rsync -aW --del --protocol=28 "$d" "$LSTMP" && cd "$LSTMP/$b" &&' \ - 'test -n "`git status --short`" && echo "$d"' && - -cd "$HOME"/tmp && exec rm -rf ls-status-carefully.tmp + 'test -n "`git status --short`" && echo "$d"' diff --git a/status-dirty-carefully b/status-dirty-carefully index 26ab5ba..4298b09 100755 --- a/status-dirty-carefully +++ b/status-dirty-carefully @@ -1,13 +1,14 @@ #! /bin/sh +STMP="$HOME"/tmp/status-dirty-carefully.tmp +export STMP +trap 'exec rm -rf "$STMP"' 0 HUP INT QUIT TERM + cd "`dirname \"$0\"`" && prog_dir="`pwd`" && -cd "$HOME"/tmp && rm -rf status-dirty-carefully.tmp && +rm -rf "$STMP" && mkdir "$STMP" && -STMP="$HOME"/tmp/status-dirty-carefully.tmp && for d in `"$prog_dir"/ls-dirty` do echo "----- $d -----" && rsync -aW --del --protocol=28 "$d" "$STMP" && - cd "$STMP/`basename $d`" && git status --branch -done && - -cd "$HOME"/tmp && exec rm -rf status-dirty-carefully.tmp + cd "$STMP/`basename \"$d\"`" && git status --branch +done -- 2.39.5