Skip to main content
16 events
when toggle format what by license comment
Jul 17, 2023 at 9:27 comment added Stéphane Chazelas @ak2, I don't expect there be. Is suppose I hadn't realised =() also worked or possibly it didn't work in older versions.
Jul 10, 2023 at 11:37 comment added ak2 Does it make a difference whether =(:) or =() is used in zsh?
Apr 24, 2022 at 14:06 history edited Stéphane Chazelas CC BY-SA 4.0
added 143 characters in body
Apr 24, 2022 at 13:45 history edited Stéphane Chazelas CC BY-SA 4.0
added 499 characters in body
Apr 24, 2022 at 6:40 comment added G-Man Says 'Reinstate Monica' (Cont’d) …  (2) The /dev/fd/3 answer fails for Bash 4.1.17 under Cygwin.  I was able to get it to work by changing var=$(cat<&3) to var=$(cat /dev/fd/3).  Perhaps this is a result of the way Cygwin handles dup?  (3) What is print?  A ksh builtin?
Apr 24, 2022 at 6:40 comment added G-Man Says 'Reinstate Monica' (1) +1, because complex_function > tmpfile; myvar=$(<tmpfile) is probably the best answer to the question for bash (with the caveat that you may need to use myvar=$(cat tmpfile) in some other shells). How on earth did nobody else suggest this in four months? (1b) I’m surprised that you didn’t even link to an answer explaining how to preserve multiple newlines at the end of a command substitution. … (Cont’d)
Apr 15, 2022 at 19:05 comment added alchemy Edited: That is interesting. I cant read the syntax very easily, (maybe you could add some explanation as inline comments), but it looks like myfunction output is sent to a 'file descriptor' and then to a var. I dont know what the temp file is doing, maybe clearing the fd, but it looks like the new_value is set just in running myfunction inside { }. Does it need all the other stuff?
Apr 15, 2022 at 18:33 comment added Stéphane Chazelas @alchemy, { ...; } is for grouping commands. If { ...; } is part of a pipeline, a subshell will still be introduced (caused by the piping, not by {...;}. Redirection (as with myfunction > /dev/fd/3 or { ...; } 3<<< '') don't cause a subshell in bash (it did in the Bourne shell).
Apr 15, 2022 at 18:30 comment added alchemy Sure, makes sense to me. So on Bash, does using { } allow changing a global variable? It didnt in my tests.
Apr 15, 2022 at 17:58 comment added Stéphane Chazelas @alchemy, see if my latest edit makes it clearer what I actually meant.
Apr 15, 2022 at 17:57 history edited Stéphane Chazelas CC BY-SA 4.0
added 282 characters in body
Apr 12, 2022 at 2:13 comment added alchemy those two options do actually allow changing shell variables: see my answer unix.stackexchange.com/a/698694/346155
Apr 11, 2022 at 6:46 comment added Stéphane Chazelas @alchemy, I don't see how lastpipe would help. Even if you meant myfunction | IFS= read -rd '' var, myfunction would still run in a subshell.
Apr 11, 2022 at 5:33 history edited Stéphane Chazelas CC BY-SA 4.0
added 13 characters in body
Apr 10, 2022 at 22:27 comment added alchemy interesting about the <<< temp file.. you can also write to "global" shell variables after using the shell options shopt -s lastpipe && set +m
May 15, 2017 at 18:03 history answered Stéphane Chazelas CC BY-SA 3.0