Skip to main content
10 events
when toggle format what by license comment
Apr 11, 2024 at 10:05 vote accept MathematicalOrchid
Feb 24, 2024 at 20:20 comment added Joe Casadonte As did I (and I've learned more from your posts over the last decade than you will ever know), so thank you, too!
Feb 24, 2024 at 14:52 comment added Charles Duffy @JoeCasadonte, ...that said, I did learn something here -- thank you!
Feb 24, 2024 at 14:52 history edited Charles Duffy CC BY-SA 4.0
added 389 characters in body
Feb 24, 2024 at 14:48 comment added Charles Duffy @JoeCasadonte, in your example above, the env command isn't doing any of the work; set -x changes SHELLOPTS in addition to changing the shell's local state, and export SHELLOPTS tells the shell to copy SHELLOPTS to the environment. Those are the only two moving parts that do anything important.
Feb 24, 2024 at 2:47 comment added Joe Casadonte I had a running Java process (that I could not stop/restart) invoking a shell script, and I needed to turn on xtrace for the shell script and its child scripts, so I did not have the luxury of running env var=val cmd.... As for env not being capable of modifying the shell's state, I think the difference is that, for me, it was modifying the shell script's state. Here's an example with two scripts: /tmp/sleeper (date; sleep 1;) and /tmp/agent (/tmp/sleeper; env SHELLOPTS=xtrace; export SHELLOPTS; set -x; /tmp/sleeper;) -- run /tmp/agent.
Feb 10, 2024 at 1:40 comment added Charles Duffy @JoeCasadonte, that doesn't make sense: env SHELLOPTS=xtrace; ... doesn't set SHELLOPTS for any subsequent command in POSIX-compliant shells. (env is an external executable, /usr/bin/env, not a built-in shell feature; as such, it's not capable of modifying the shell's state; whereas env var=val cmd ... tells env to first set var=val in its own environment and then use execve() to replace itself with cmd).
Feb 9, 2024 at 20:06 comment added Joe Casadonte In my case I could not invoke the script this way, I had to add it to a script being spawned via Java. To do that I added the following to the script: env SHELLOPTS=xtrace; export SHELLOPTS; set -x
Apr 15, 2021 at 2:44 review Low quality posts
Apr 15, 2021 at 10:21
Apr 15, 2021 at 1:28 history answered Charles Duffy CC BY-SA 4.0