Skip to main content

$@ in alias inside script: is there a "local" $@? [Resolved]

I have aliased pushd in my bash shell as follows so that it suppresses output:

alias pushd='pushd "$@" > /dev/null'

This works fine most of the time, but I'm running into trouble now using it inside functions that take arguments. For example,

test() {
  pushd .

Running test without arguments is fine. But with arguments:

> test x y z
bash: pushd: too many arguments

I take it that pushd is trying to take . x y z as arguments instead of just .. How can I prevent this? Is there a "local" equivalent of $@ that would only see . and not x y z?

Question Credit: Théophile
Question Reference
Asked August 18, 2019
Posted Under: Unix Linux
1 Answers

Your Answer