bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing documentation "-bash_input"


From: Greg Wooledge
Subject: Re: Missing documentation "-bash_input"
Date: Tue, 28 Nov 2023 19:43:48 -0500

On Wed, Nov 29, 2023 at 12:37:55AM +0000, Klaus Frank wrote:
> One thing though, I probably should already know that, but why is a $0
> needed even though a command was already specified? Shouldn't the command
> itself be $0?

It's simply how sh -c has always worked.  The first argument after -c
is the script to be executed.  The second argument after -c becomes $0
of the script, the third becomes $1, and so on.

If you want to pass positional parameters to the -c script, therefore,
you must put *something* in the slot between the script and the parameters.
That something becomes $0.  Common choices are sh, bash, _ and x but you
can use pretty much any string.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]