-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlooper
More file actions
executable file
·50 lines (49 loc) · 1.22 KB
/
Copy pathlooper
File metadata and controls
executable file
·50 lines (49 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
if [ "$1" = '--help' ]; then
exit 1
elif [ "$1" = '--version' ]; then
exit 1
fi
##region########################################### GET PATH, DIR, & NAME ###########################################
readonly MY_PATH=$(realpath "$0")
MY_DIR=''
MY_NAME=''
if [[ "$MY_PATH" =~ ^(.*)/([^/]+)$ ]]; then
readonly MY_DIR="${BASH_REMATCH[1]}" MY_NAME="${BASH_REMATCH[2]}"
else
readonly MY_DIR="$HOME" MY_NAME="$0"
echo "$MY_NAME: Failed to get dir" 1>&2
exit 1
fi
##endregion######################################## GET PATH, DIR, & NAME ###########################################
readonly LOGFILE="$MY_DIR/$MY_NAME.log.txt"
declare -i current_count=0
# date +'%T %D' >> $LOGFILE
l_exit() {
# shellcheck disable=SC2086
# shellcheck disable=SC2317
echo "Early exit"
exit 200
}
trap l_exit INT
trap l_exit QUIT
trap l_exit TERM
# trap exit KILL
echo -n $current_count
# echo -n $current_count >>$LOGFILE
while (( current_count < 10 )); do
sleep 1
((current_count+=1))
# echo -n "$current_count"
if (( current_count & 1 == 1 )); then
echo -n "$current_count "
# echo -n "$current_count " >>$LOGFILE
else
echo -n "$current_count
"
# echo -n "$current_count
# " >>$LOGFILE
fi
done
# echo $current_count
exit $current_count