Reputation
1,683
Top tag
Next privilege 2,000 Rep.
Edit questions and answers
Badges
3 16 37
Impact
~139k people reached

Jan
21
awarded  Popular Question
Jan
2
accepted See if a script is running when using #!/usr/bin/env
Jan
1
comment See if a script is running when using #!/usr/bin/env
-z it supports, but for some reason it fails when I use -z together with -q, but that can be solved with >/dev/null. Now I'll give your command some tries, thanks!
Jan
1
comment See if a script is running when using #!/usr/bin/env
I have upgraded my sed, but when running your command, I get xargs: sed: terminated by signal 13.
Jan
1
comment See if a script is running when using #!/usr/bin/env
Hello, Happy New Year! What version of sed is this that supports null-separated new-lines? Mine doesn't: GNU sed 4.2.1.
Dec
30
revised See if a script is running when using #!/usr/bin/env
added 2 characters in body
Dec
30
revised See if a script is running when using #!/usr/bin/env
deleted 7 characters in body
Dec
30
asked See if a script is running when using #!/usr/bin/env
Dec
23
awarded  Nice Question
Nov
25
awarded  Notable Question
Nov
12
awarded  Nice Question
Oct
23
awarded  Popular Question
Sep
30
awarded  Notable Question
Sep
20
comment Is this a bug in bash? `return` doesn't quit function if called from a pipe
@cuonglm I removed that edit yesterday. It actually happens in non-interactive mode too. Sorry for that!
Sep
20
awarded  Nice Question
Sep
20
comment Is this a bug in bash? `return` doesn't quit function if called from a pipe
@LightnessRacesinOrbit A while loop is a very common usage for a pipe with return. The second example is more straight to the point, but it is something I don't believe anyone would ever use...
Sep
19
accepted Is this a bug in bash? `return` doesn't quit function if called from a pipe
Sep
19
comment Is this a bug in bash? `return` doesn't quit function if called from a pipe
@jlliagre It is a rather complex script on the thousands of lines. With the concern of breaking something else, I prefer to just avoid running a pipe within the function, so I replaced it with a process substitution. Thanks!
Sep
19
comment Is this a bug in bash? `return` doesn't quit function if called from a pipe
@Scott I think I understand the situation well. A pipe creates a subshell, and return is returning from the subshell instead of failing, since it is inside an actual function. The problem is that help return specifically states: Causes a function or sourced script to exit with the return value specified by N. From reading the documentation, any user would expect it to at least fail or print a warning, but never to behave like exit.
Sep
19
comment Is this a bug in bash? `return` doesn't quit function if called from a pipe
Since return won't quit the function, wouldn't it make more sense if the shell just printed bash: return: can only `return' from a function or sourced script, instead of giving the user a false sense that the function might have returned?