You are not logged in.

#1 2026-06-07 19:29:17

lo7777799
Member
Registered: 2023-07-25
Posts: 87

#!/usr/bin/env -S bash -x

good evening,

i have a question ... in that title is a command with env and bash ...

what does "-S" mean?

in man stays, that S is for separate ...

in my book it is not explained good ... does -S activate, that "-x" is a flag for env or "-x" is a flag for bash or "-x" is not a part of the name, that "bash -x" is not name of shell and "bash" without "-x" is name of shell?

what case above does -S mean?

it is not well explained in my book. can you answer to my questions please?

Last edited by lo7777799 (2026-06-07 19:29:33)

Offline

#2 2026-06-07 19:43:52

jonno2002
Member
Registered: 2016-11-21
Posts: 868

Offline

#3 Yesterday 12:42:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,459
Website

Re: #!/usr/bin/env -S bash -x

Why ask, test and learn:

$ cat test.sh
#!/bin/env bash -x
echo one
echo two

$ ./test.sh
env: ‘bash -x’: No such file or directory
env: use -[v]S to pass options in shebang lines

$ vim test.sh    # edit to add -S flag

$ cat test.sh
#!/bin/env -S bash -x
echo one
echo two

$ ./test.sh
+ echo one
one
+ echo two
two

So just as the man page says:

man env wrote:

-S, --split-string=S
              process  and  split  S into separate arguments; used to pass multiple arguments on shebang lines

Without the -S flag to 'env' the command it tries to execute is 'bash -x' which is not the name of an executable in the PATH.  With the -S, it does just as the man page says and splits that into multiple arguments of 'bash' and '-x'.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 Yesterday 13:16:11

ReDress
Banned
From: Nairobi
Registered: 2024-11-30
Posts: 350

Re: #!/usr/bin/env -S bash -x

Certain professions don't allow for trying/testing/whatever you might call it.

Sure enough you could always try but the fact that you can try/test/whatever *simply* increases margin for error.

Offline

#5 Yesterday 16:16:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,459
Website

Re: #!/usr/bin/env -S bash -x

Ah, right, sure.  But shell scripting is not one of those professions.  Experimenting with scripting is the best way to learn.  So I'm really not sure what you're on about unless you are just trying to stir shit up.

Last edited by Trilby (Yesterday 20:36:18)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB