Skip to content

Commit

Permalink
{basic,modular}: feat: Introducing convenience variables for the base…
Browse files Browse the repository at this point in the history
… command and command-line arguments

Signed-off-by: 林博仁(Buo-ren, Lin) <[email protected]>
  • Loading branch information
brlin-tw committed Mar 23, 2024
1 parent ba950bd commit 602b0f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Inherited from the [BARE-MINIMUM](#bare-minimum) flavor, but with the following
+ `script_dir`: The absolute path of the directory that contains the shell script
+ `script_filename`: The full filename of the shell script
+ `script_name`: The name of the shellscript, excluding the filename suffixes
+ `script_basecommand`: The base command(without arguments) when running the script
+ `script_args`: An array containing all the command-line arguments when running the script

## [MODULAR](modular.sh)

Expand Down
6 changes: 6 additions & 0 deletions basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ if test -v BASH_SOURCE; then
script_name="${script_filename%%.*}"
}
fi
# Convenience variables may not need to be referenced
# shellcheck disable=SC2034
{
script_basecommand="${0}"
script_args=("${@}")
}

printf \
'Info: Operation completed without errors.\n'
6 changes: 6 additions & 0 deletions modular.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ if test -v BASH_SOURCE; then
script_name="${script_filename%%.*}"
}
fi
# Convenience variables may not need to be referenced
# shellcheck disable=SC2034
{
script_basecommand="${0}"
script_args=("${@}")
}

trap_err(){
printf \
Expand Down

0 comments on commit 602b0f6

Please sign in to comment.