For bash script, I can use
ANSWER:-
"$@"
to access arguments. What's the equivalent when I use an alias?ANSWER:-
Aliases are like commands in that all arguments to them are passed as arguments to the program they alias. For instance, if you were to alias
ls
to ls -la
, then typing ls foo bar
would reallyexecute ls -la foo bar
on the command line.
If you want to have actual control over how the arguments are interpreted, then you could write a function like so:
my_program_wrapper() {
local first_arg="$1" \
second_arg="$2"
shift 2 # get rid of the first two arguments
# ...
/path/to/my_program "$@"
}
0 comments:
Post a Comment
Don't Forget to comment