How to pass positional arguments to an interactive bash session

Viewed 119

I wanted to start an interactive bash shell like this :

bash (...some options) 1 2 3

so that in the shell session, I have $1=1, ...

I didn't find any options to achieve the effect.

I tried this, thought it might work :

bash -c bash _ 1 2 3

but it didn't.

1 Answers

From bash invoking bash:

-s

If this option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.

$ bash -s 1 2 3
$ echo $1
1 
$ exit
$
Related