-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop-thru
More file actions
executable file
·49 lines (37 loc) · 814 Bytes
/
loop-thru
File metadata and controls
executable file
·49 lines (37 loc) · 814 Bytes
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
#!/usr/bin/env bash
OLDPWD=$PWD
PWD="$HOME/Downloads"
echo "Switching directory to: $PWD"
back-to-previous-directory() {
echo -n "Going back to previous working directory: "
cd -
}
ctrl-c() {
echo -e "\n"
back-to-previous-directory
exit
}
check-command() {
if [[ "$#" -lt "1" ]]; then
cat <<- BLOCK
Please put the aurgumens as in following orders:
$ ${0##*/} one_command --some-option --another-option
Thank you!
BLOCK
back-to-previous-directory
exit 1
fi
if [[ ! $(command -v "$1") ]]; then
echo "Command does not exist!"
back-to-previous-directory
exit 1
fi
}
# Script begin here
check-command "$@"
trap ctrl-c SIGINT
echo "Feel free to paste multi-strings and the script will do the work"
while read url; do
eval \$@ "\$url"
echo -e "\n?:$? Ctrl-C to Exit\n"
done