Skip to content

Commit 602b0f6

Browse files
committed
{basic,modular}: feat: Introducing convenience variables for the base command and command-line arguments
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
1 parent ba950bd commit 602b0f6

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Inherited from the [BARE-MINIMUM](#bare-minimum) flavor, but with the following
2727
+ `script_dir`: The absolute path of the directory that contains the shell script
2828
+ `script_filename`: The full filename of the shell script
2929
+ `script_name`: The name of the shellscript, excluding the filename suffixes
30+
+ `script_basecommand`: The base command(without arguments) when running the script
31+
+ `script_args`: An array containing all the command-line arguments when running the script
3032

3133
## [MODULAR](modular.sh)
3234

basic.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ if test -v BASH_SOURCE; then
6767
script_name="${script_filename%%.*}"
6868
}
6969
fi
70+
# Convenience variables may not need to be referenced
71+
# shellcheck disable=SC2034
72+
{
73+
script_basecommand="${0}"
74+
script_args=("${@}")
75+
}
7076

7177
printf \
7278
'Info: Operation completed without errors.\n'

modular.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ if test -v BASH_SOURCE; then
7272
script_name="${script_filename%%.*}"
7373
}
7474
fi
75+
# Convenience variables may not need to be referenced
76+
# shellcheck disable=SC2034
77+
{
78+
script_basecommand="${0}"
79+
script_args=("${@}")
80+
}
7581

7682
trap_err(){
7783
printf \

0 commit comments

Comments
 (0)