You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing scripts in bash, I always use some combination of:
set -e (fail if any command fails)
set -u (fail if any undefined variable is referenced)
set -x (print each command before it's executed)
set -o pipefail (a failed command in a pipeline will cause the parent command to fail)
Additionally, it would be nice to have an option like pipefail that applies to subshells (i.e causes echo (false) to return nonzero status).
It doesn't seem like any of these are available in fish, which doesn't usually matter for interactive use but kills it as a scripting language for me (which is a shame, because fish's sensible variable-expansion would make it much harder to accidentally get quoting wrong).
Any chance of adding similar features?
Reacted by Actionless Loveless, Olivier Dupré, Marco Borgeaud, Ivan Kozik, Viktor Stanchev, Adam Quinn Snow, Ryan, Andrew, anatoly techtonik, Marcin Zajączkowski and 11 more
I'm inclined to suggest that strict mode should be the default and the only option, and we should instead provide escape hatches for more lenient execution. One problem with this though is that if ; is ; and then ; or is ; and or which doesn't really work, so we'd have to special case that or redesign and/or.
set -x could perhaps be an argument for the fish executable.
Reacted by Andreas Nordal, Jan Tojnar, Ryan, anatoly techtonik, Marcin Zajączkowski, Rick Beton and Josh Junon
-x could also be an option to begin, if it's possible for begin to take arguments. I often have individual sections of script with -x disabled if they produce a lot of useless logging, so it'd be nice to control this at a finer level than at process startup.
Yes, and/or is a problem (well, actually only or is). Without special casing, I'm not sure there's much we can do. It does provide one argument for making them part of the syntax though as opposed to just builtins.
Also, if -u is a default then there should be convenience method for defaulting variables, i.e some more readable and terse version of if not set -q y; set y "default"; end.
I do think it's a bit odd that wildcards error when not matched but undefined variables don't. I guess another option would be the inverse: make non-matching wildcards expand to empty lists. That would probably be even less convenient and even more confusing than the current behavior, though, since now if you do e.g. wget some/url/*.txt you end up running wget with no arguments and it prints usage hints, instead of the more helpful fish error for unmatched wildcard.
Yep, I'd definitely rather more things be strict than less (wildcards are a perfect example, being lenient about them only causes errors later, which can be dangerous).
If we have a strict mode, then we will need to ensure that all of fish's provided functions work correctly in strict mode.
fail if any undefined variable is referenced
This seems like a weird thing to give the user a choice about. We should just figure out what the right behavior is and implement that.
fail if any command fails
fish relies more heavily on functions than most shells, and most functions cannot easily be made compatible with this. So this option ought to be lexically scoped, like local variables, so it applies to only a block of code, and not function calls.
A more idiomatic way to do this in fish would be an event handler, something like this:
function die --on-event command-failed
exit
end
but I'm not sure how this could be lexically scoped.
print each command before it's executed
This seems like it would be better suited as an option to the fish executable, like the existing --no-execute.
a failed command in a pipeline will cause the parent command to fail
I think it would be error-prone and not fishy to make fundamental pipeline behavior depend on distant configuration options. Ideally you would want to specify this the pipeline itself.
Three ideas that I think are pretty good:
Make and work in pipelines (currently it is disallowed). Then we could write for example:
grep root /etc/passwd | and cut -f5 -d:
which is a beautiful and intuitive syntax.
We would need to decide on the behavior of and in a pipeline. Would it be true to itself, and not execute the cut command at all? Or would it still execute the command, and just affect the exit status?
Add a new variant of the pipe which accumulates $status, say, |&
grep root /etc/passwd |& cut -f5 -d:
This seems like a nice syntax as well.
Just make pipefail the default any only behavior of pipes. Any reason why it should not be?
A few other ideas which I think are bad:
Add a separate variable $pipestatus which tracks $status, except it's nonzero if any command in the pipeline failed. It's unclear how this would be reflected into $status for the purpose of if statements, etc.
Add a separate variable $failcount which tracks how many commands have failed. You would use it like so: set failcount 0; foo | bar | baz; if test $failcount -ge 0 ...
Add a builtin pipe which can head a pipeline and configure it in various ways. pipe --overall-status | foo | bar.
With something like set -d, I think this makes sense to be the default (and only) behaviour.
fail if any command fails
fish relies more heavily on functions than most shells, and most functions cannot easily be made compatible with this
I don't understand why - I would have though that to implement this, a function failure would be treated like a command failure. And a failed command call made in a function would cause the function to also fail.
Regarding:
grep root /etc/passwd | and cut -f5 -d:
I don't think you could prevent cut from running if grep failed - something like tail -f would run indefinitely, so you'd need to start cut sometime. So it'd be more of a propagation of status codes rather than changing what gets run.
As an aside, I think and should be the default behvaiour (especially if "fail if any command fails" is the default - otherwise it's inconsistent).
Is there a way to preemtively allow a command to fail? i.e instead of modifying the syntax to allow a failed command if it's followed by an or, perhaps just introduce a builtin ("try"?) that runs the given command and returns its exit code but prevents the fail-on-error behaviour, Some examples:
try grep root /etc/passwd | cut -f5 -d: ; or echo "no root!"
# (cut would be run in this case, but do nothing)
try rm /whatever
# allowed to fail, you can still inspect $status to check whether it did
It would be great to have strict mode to be enforceable for certain functions, not necessary for the whole fish-script. Currently I have a set of functions, which looks like this:
function update_dump -d"Downloads new version of dump, then imports it to DB"
rsync -av--progress ...:~/dump.tar.gz dump.tar.gz;\and tar xzf ./dump.tar.gz;\and rake db:drop db:create;\and psql development < ./dev.sql;\andrm ./dev.sql;\and rake db:migrate db:test:prepare
end
Ideally I would like to have something like this:
function update_dump --strict-d"Downloads new version of dump, then imports it to DB"
rsync -av--progress ...:~/dump.tar.gz dump.tar.gz
tar xzf ./dump.tar.gz
rake db:drop db:create
psql development < ./dev.sql
rm ./dev.sql
rake db:migrate db:test:prepare
end
I would like to vouch for this issue. Creating a less cryptic syntax for shell scripting is a noble cause and since fish is on the right track, it would be good not to focus only on the interactive part.
A more idiomatic way to do this in fish would be an event handler, something like this:
function die --on-event command-failed
exit
end
but I'm not sure how this could be lexically scoped.
Solving this problem in general would be very useful. I've run into wanting to cd just for the duration of a function. (So did these guys.) It sounds like the same solution could apply there.
The brute force answer might be to make blocks aware of the cwd and of event listeners and other things like that, so that then we could have some special command for block-scoped-cd or block-scoped-on-signal. But that seems like a lot of special casing and work. One idea that seems to work well is what Python does with context managers. If there was some mechanism for defining a function to "do work now -- and then do this other thing when the current block ends", then it would be super easy to define block-scoped cd and listeners and everything else, and fish could consider defining some of those functions by default too.
Special casing or for strict mode makes sense to me, unless that would be a huge change in the way or is implemented now. (Is it actually just a regular command?)
Just make pipefail the default any only behavior of pipes. Any reason why it should not be?
That sounds great. For commands in a pipe whose exit status you want to suppress, you can use do something like this (assuming or does get special-cased):
... | begin command_with_weird_error_codes; or true; end | ...
This is the same thing you'd do in bash with pipefail on, just with fish's grouping syntax. Alternatively, you could define a function that does the same thing, and put that in the pipe.
I also agree with this. I've been trying to write a fish script that does a variety of things with command line arguments, and it's been difficult. Maybe fish scripts don't fit well here...?
Yes, set -x is for debugging, and there are other ways to debug that are nearly as good. Plus, people tend to clean up their debug printouts when done debugging, as opposed to leaving set -x enabled, which I'm no fan of – I agree with Dag that it could be an option to fish. Anyway, I think set -x is a separate discussion, as it doesn't make the language any stricter. set -euo pipefail is bash's strict mode.
But while I'm at it:
echo $cmd
My favourite is echo «$cmd». Exploits cartesian product to print each argument enclosed in those funny guillemet quotes (choose something funny on your keyboard) so you can tell the arguments apart in case they contain whitespace.
in bash, set -e is useless in interactive mode because any failing command logs you out. But I think it should be possible to have the same strict language (wrt. failure propagation) interactively, and just not get logged out.
backward compatibility (with people's scripts). Or we could do it for fish 3.0 and forget about backward compatibility (à la python3).
fail if any command fails
fish relies more heavily on functions than most shells, and most functions cannot easily be made compatible with this
I don't understand why - I would have thought that to implement this, a function failure would be treated like a command failure. And a failed command call made in a function would cause the function to also fail.
I don't understand either. Are return values hard to control? Do we use $status to communicate other things than failure? I do know a builtin that does that: count with no arguments returns 1 on success. We have at least 15 functions that depend on that (grep for "if count"). In my mind, that just means we must fix those as well. As a first step, the documentation should avoid advertising any entropy in $status on success.
@anordal I agree this should work fine in interactive mode. Every real language with fatal errors doesn't exit the REPL when one is encountered.
Comparability is still a concern though---consensus to a make a breaking release doesn't mean the problem goes a way but just that people decided to move forwards despite it.
Having had to contend with side effects of rbenv’s decision to go “strict” I can only deem idiotic [1, 2], I must say I am less than sold on it. I tend to agree with GreyCat’s assessment that bash’s set -eis a non-feature, bordering on an antipattern, very much inferior to explicit error checking.
@kopischke I agree that bash's set -e is broken, and introduces as many subtle gotchas as it alleviates. But... I think that's just sh being sh and not an idea with the problem itself?
See my comment in #805 (comment) I think sh's crucial mistake was to approach the mode from a "failure means exit" perspective. Then things like x=${foo} and if false ... are important exceptions to the rule. If one thinks instead in terms of making sure errors are not implicitly ignored, as I say in comment, then it's clear that the assignment to x "remember" the exit status, and if handles the exit status, so aborting should not be done.
Not only is this a good mental model for the fish user, but it also lends itself to an implementation strategy (make sure whatever holds the exit status isn't destroyed but moved), so I'm confident that we can avoid gotchas.
IMO, the correct way to think about strict mode is not that things terminate on error, but that ignored error codes are bubbled up until something inspects them.
Well, that is certainly a much more sane concept than the errexit mess, but I am still dubious: what bit the rbenv-plugin developers in the, ahem, lower back, and what I tried to fix was the assumption that return codes above 0 signal an error, when, in the case of grep, the code is a Boolean return value.
With exit values the only reliable way to communicate results without worrying about stdout or stderr (which can be suppressed and often have another dedicated use, as is the case for grep), that kind of behaviour makes sense and is orthogonal to the assumption that non-zero is an error. bash’s errexit adds insult to injury, but at the core is an issue every “error handling” mechanism will have to cope with, barring us all starting to use something like PowerShell.
Also is it so drastic if strict mode is optional?
That depends entirely on how painless it is to break out of its scope, be it in plugins / extensions / subscripts or globally without affecting the main script, I’d say.
Thanks for your links to the ruby issues - very instructive. One idea I had is that strict mode is a property of a scope. This would avoid opting code like plugins in when they don't expect it. Do you think that would help?
Yeah strict mode can and should be lexical. I'd like it to eventually become mandatory (say with breaking, major number bump, fish release), but even then we have three kinds of blocks: do all commands, break at first failure, break at first success. (Look earlier in the thread to read more about this.)
@kopischke In your case I see two principles. If the non-standard error codes are explicitly handled, then no implicit aborts will happen. If the non-standard error codes are not implicitly handled, then whatever information they additionally encode will be discarded anyways. I'd make a function, taking a command and args, which calls the command than converts the error code to the standard. Then the error code of the function will be handled implicit by strict mode in the original script, which will be the correct behavior.
Agree that when it comes to modes, lexical scoping is preferrable over global state. But what about inner scopes (such as if, while, for and so on) of a strict mode scope, are they also strict? I think they ought to be, all the way in to a scope that is explicitly not, but not cross function boundaries:
begin--break-on-failureiftrue# still in strict modebegin--no-break-on-failure# strict mode disabledendendend
Alternatively, it could be purely a function-scope thing.
I think the requirements are:
it must not cross software module boundaries. I suppose not crossing function boundaries would satisfy this.
it makes sense to restrict the number of places one has to look for it
as a safety feature, it's not good if it's easy to accidentally disable by adding an inner scope
Reason for (2): You cannot proofread a piece of code without knowing if strict mode is on or off: In normal mode, you must handle the errors; in strict mode you must handle the non-errors (usually by ; or true). Expected errors should be handled anyway, for human readable error messages, but that's a different concern.
the assumption that return codes above 0 signal an error, when, in the case of grep, the code is a Boolean return value.
aka. the non-errors. But depends on context, as you would consider it an error if grep doesn't find the match in a situation where you expect it to.
Reason for (3): The way I look at all kinds of strict mode, they are safety features: They make sloppy code fail, so the paranoid programmer can know that the code is free of certain classes of bugs. Specifically with --break-on-failure, that if the program works, it means that no exit status handling is missing.
it must not cross software module boundaries. I suppose not crossing function boundaries would satisfy this.
Presumably this rule also includes source since it represents a module boundary akin to python's import.
FWIW, I used to use set -e (or set --errexit) a lot. Then I learned better habits and stopped using it for the crutch that it is. So I'm not a fan of introducing it to fish but do recognize for certain classes of scripts it has utility. If we do add this feature it absolutely has to have lexical scoping and function and module boundaries represent different lexical scopes. It also must not be the default behavior.
Closing this as a duplicate of issue #510. While it is true this issue was originally broader than just dealing with unhandled command failures the fact is the discussion has been focused almost solely on the latter. So I'm going to close this as a duplicate of #510. Other topics, such as a bash set -x equivalent for fish should be discussed in issues dealing with each specific feature (e.g., #3427).
Activity
dag commentedon May 22, 2013
We loathe options and configuration in fish. 😉
I'm inclined to suggest that strict mode should be the default and the only option, and we should instead provide escape hatches for more lenient execution. One problem with this though is that if
;is; andthen; oris; and orwhich doesn't really work, so we'd have to special case that or redesignand/or.set -xcould perhaps be an argument for thefishexecutable.dag commentedon May 22, 2013
Oh and it would mean making
;andcommandline -f executebehave differently, which may or may not be a problem.timbertson commentedon May 22, 2013
I'd love strict mode to be the default.
-xcould also be an option tobegin, if it's possible for begin to take arguments. I often have individual sections of script with-xdisabled if they produce a lot of useless logging, so it'd be nice to control this at a finer level than at process startup.Yes,
and/oris a problem (well, actually onlyoris). Without special casing, I'm not sure there's much we can do. It does provide one argument for making them part of the syntax though as opposed to just builtins.Also, if
-uis a default then there should be convenience method for defaulting variables, i.e some more readable and terse version ofif not set -q y; set y "default"; end.dag commentedon May 22, 2013
But maybe a
set -dis warranted.I do think it's a bit odd that wildcards error when not matched but undefined variables don't. I guess another option would be the inverse: make non-matching wildcards expand to empty lists. That would probably be even less convenient and even more confusing than the current behavior, though, since now if you do e.g.
wget some/url/*.txtyou end up running wget with no arguments and it prints usage hints, instead of the more helpful fish error for unmatched wildcard.timbertson commentedon May 22, 2013
Yep, I'd definitely rather more things be strict than less (wildcards are a perfect example, being lenient about them only causes errors later, which can be dangerous).
set -dsounds like a good idea to me.ridiculousfish commentedon Jun 9, 2013
If we have a strict mode, then we will need to ensure that all of fish's provided functions work correctly in strict mode.
This seems like a weird thing to give the user a choice about. We should just figure out what the right behavior is and implement that.
fish relies more heavily on functions than most shells, and most functions cannot easily be made compatible with this. So this option ought to be lexically scoped, like local variables, so it applies to only a block of code, and not function calls.
A more idiomatic way to do this in fish would be an event handler, something like this:
but I'm not sure how this could be lexically scoped.
This seems like it would be better suited as an option to the fish executable, like the existing
--no-execute.I think it would be error-prone and not fishy to make fundamental pipeline behavior depend on distant configuration options. Ideally you would want to specify this the pipeline itself.
Three ideas that I think are pretty good:
Make
andwork in pipelines (currently it is disallowed). Then we could write for example:which is a beautiful and intuitive syntax.
We would need to decide on the behavior of
andin a pipeline. Would it be true to itself, and not execute thecutcommand at all? Or would it still execute the command, and just affect the exit status?Add a new variant of the pipe which accumulates $status, say, |&
This seems like a nice syntax as well.
Just make pipefail the default any only behavior of pipes. Any reason why it should not be?
A few other ideas which I think are bad:
$pipestatuswhich tracks$status, except it's nonzero if any command in the pipeline failed. It's unclear how this would be reflected into$statusfor the purpose of if statements, etc.$failcountwhich tracks how many commands have failed. You would use it like so:set failcount 0; foo | bar | baz; if test $failcount -ge 0 ...pipewhich can head a pipeline and configure it in various ways.pipe --overall-status | foo | bar.timbertson commentedon Jun 10, 2013
With something like
set -d, I think this makes sense to be the default (and only) behaviour.I don't understand why - I would have though that to implement this, a function failure would be treated like a command failure. And a failed command call made in a function would cause the function to also fail.
Regarding:
I don't think you could prevent
cutfrom running if grep failed - something liketail -fwould run indefinitely, so you'd need to startcutsometime. So it'd be more of a propagation of status codes rather than changing what gets run.As an aside, I think
andshould be the default behvaiour (especially if "fail if any command fails" is the default - otherwise it's inconsistent).Is there a way to preemtively allow a command to fail? i.e instead of modifying the syntax to allow a failed command if it's followed by an
or, perhaps just introduce a builtin ("try"?) that runs the given command and returns its exit code but prevents the fail-on-error behaviour, Some examples:andrusha commentedon Mar 29, 2014
It would be great to have strict mode to be enforceable for certain functions, not necessary for the whole fish-script. Currently I have a set of functions, which looks like this:
Ideally I would like to have something like this:
najamelan commentedon Apr 18, 2014
I would like to vouch for this issue. Creating a less cryptic syntax for shell scripting is a noble cause and since fish is on the right track, it would be good not to focus only on the interactive part.
ridiculousfish commentedon Apr 18, 2014
Along the same lines, we could support a
--strictoption for begin as well.oconnor663 commentedon Jul 26, 2015
Solving this problem in general would be very useful. I've run into wanting to
cdjust for the duration of a function. (So did these guys.) It sounds like the same solution could apply there.The brute force answer might be to make blocks aware of the cwd and of event listeners and other things like that, so that then we could have some special command for block-scoped-cd or block-scoped-on-signal. But that seems like a lot of special casing and work. One idea that seems to work well is what Python does with context managers. If there was some mechanism for defining a function to "do work now -- and then do this other thing when the current block ends", then it would be super easy to define block-scoped cd and listeners and everything else, and fish could consider defining some of those functions by default too.
Ericson2314 commentedon Jul 31, 2015
For the
orproblem. we could preserve the meaning of;,; and, and; or, but make it so that newlines have the meaning of; and.Might sound weird to bash users, but Rust has got me use to final
;or lack thereof making a difference.oconnor663 commentedon Jul 31, 2015
Special casing
orfor strict mode makes sense to me, unless that would be a huge change in the wayoris implemented now. (Is it actually just a regular command?)That sounds great. For commands in a pipe whose exit status you want to suppress, you can use do something like this (assuming
ordoes get special-cased):This is the same thing you'd do in bash with
pipefailon, just with fish's grouping syntax. Alternatively, you could define a function that does the same thing, and put that in the pipe.faho commentedon Sep 15, 2015
See also #510, which asks for a
set -eequivalent.nateleavitt commentedon Oct 15, 2015
I also agree with this. I've been trying to write a fish script that does a variety of things with command line arguments, and it's been difficult. Maybe fish scripts don't fit well here...?
17 remaining items
anordal commentedon Jul 8, 2016
Yes,
set -xis for debugging, and there are other ways to debug that are nearly as good. Plus, people tend to clean up their debug printouts when done debugging, as opposed to leavingset -xenabled, which I'm no fan of – I agree with Dag that it could be an option to fish. Anyway, I thinkset -xis a separate discussion, as it doesn't make the language any stricter.set -euo pipefailis bash's strict mode.But while I'm at it:
My favourite is
echo «$cmd».Exploits cartesian product to print each argument enclosed in those funny guillemet quotes (choose something funny on your keyboard) so you can tell the arguments apart in case they contain whitespace.anordal commentedon Jul 8, 2016
Why do we need a separate mode?
set -eis useless in interactive mode because any failing command logs you out. But I think it should be possible to have the same strict language (wrt. failure propagation) interactively, and just not get logged out.I don't understand either. Are return values hard to control? Do we use $status to communicate other things than failure? I do know a builtin that does that:
countwith no arguments returns 1 on success. We have at least 15 functions that depend on that (grep for "if count"). In my mind, that just means we must fix those as well. As a first step, the documentation should avoid advertising any entropy in $status on success.Ericson2314 commentedon Jul 9, 2016
@anordal I agree this should work fine in interactive mode. Every real language with fatal errors doesn't exit the REPL when one is encountered.
Comparability is still a concern though---consensus to a make a breaking release doesn't mean the problem goes a way but just that people decided to move forwards despite it.
kopischke commentedon Jul 10, 2016
Having had to contend with side effects of rbenv’s decision to go “strict” I can only deem idiotic [1, 2], I must say I am less than sold on it. I tend to agree with GreyCat’s assessment that bash’s
set -eis a non-feature, bordering on an antipattern, very much inferior to explicit error checking.Ericson2314 commentedon Jul 10, 2016
@kopischke I agree that bash's
set -eis broken, and introduces as many subtle gotchas as it alleviates. But... I think that's just sh being sh and not an idea with the problem itself?See my comment in #805 (comment) I think sh's crucial mistake was to approach the mode from a "failure means exit" perspective. Then things like
x=${foo}andif false ...are important exceptions to the rule. If one thinks instead in terms of making sure errors are not implicitly ignored, as I say in comment, then it's clear that the assignment tox"remember" the exit status, andifhandles the exit status, so aborting should not be done.Not only is this a good mental model for the fish user, but it also lends itself to an implementation strategy (make sure whatever holds the exit status isn't destroyed but moved), so I'm confident that we can avoid gotchas.
kopischke commentedon Jul 10, 2016
Well, that is certainly a much more sane concept than the
errexitmess, but I am still dubious: what bit therbenv-plugindevelopers in the, ahem, lower back, and what I tried to fix was the assumption that return codes above 0 signal an error, when, in the case ofgrep, the code is a Boolean return value.With exit values the only reliable way to communicate results without worrying about
stdoutorstderr(which can be suppressed and often have another dedicated use, as is the case forgrep), that kind of behaviour makes sense and is orthogonal to the assumption that non-zero is an error. bash’serrexitadds insult to injury, but at the core is an issue every “error handling” mechanism will have to cope with, barring us all starting to use something like PowerShell.That depends entirely on how painless it is to break out of its scope, be it in plugins / extensions / subscripts or globally without affecting the main script, I’d say.
ridiculousfish commentedon Jul 10, 2016
Thanks for your links to the ruby issues - very instructive. One idea I had is that strict mode is a property of a scope. This would avoid opting code like plugins in when they don't expect it. Do you think that would help?
kopischke commentedon Jul 10, 2016
@ridiculousfish that would certainly help: as far as I’m concerned, the more limited and explicit the scoping of this kind of feature, the better.
Ericson2314 commentedon Jul 11, 2016
Yeah strict mode can and should be lexical. I'd like it to eventually become mandatory (say with breaking, major number bump, fish release), but even then we have three kinds of blocks: do all commands, break at first failure, break at first success. (Look earlier in the thread to read more about this.)
@kopischke In your case I see two principles. If the non-standard error codes are explicitly handled, then no implicit aborts will happen. If the non-standard error codes are not implicitly handled, then whatever information they additionally encode will be discarded anyways. I'd make a function, taking a command and args, which calls the command than converts the error code to the standard. Then the error code of the function will be handled implicit by strict mode in the original script, which will be the correct behavior.
anordal commentedon Jul 17, 2016
Agree that when it comes to modes, lexical scoping is preferrable over global state. But what about inner scopes (such as
if,while,forand so on) of a strict mode scope, are they also strict? I think they ought to be, all the way in to a scope that is explicitly not, but not cross function boundaries:Alternatively, it could be purely a function-scope thing.
I think the requirements are:
Reason for (2): You cannot proofread a piece of code without knowing if strict mode is on or off: In normal mode, you must handle the errors; in strict mode you must handle the non-errors (usually by
; or true). Expected errors should be handled anyway, for human readable error messages, but that's a different concern.aka. the non-errors. But depends on context, as you would consider it an error if grep doesn't find the match in a situation where you expect it to.
Reason for (3): The way I look at all kinds of strict mode, they are safety features: They make sloppy code fail, so the paranoid programmer can know that the code is free of certain classes of bugs. Specifically with --break-on-failure, that if the program works, it means that no exit status handling is missing.
krader1961 commentedon Jul 17, 2016
Presumably this rule also includes
sourcesince it represents a module boundary akin to python'simport.FWIW, I used to use
set -e(orset --errexit) a lot. Then I learned better habits and stopped using it for the crutch that it is. So I'm not a fan of introducing it to fish but do recognize for certain classes of scripts it has utility. If we do add this feature it absolutely has to have lexical scoping and function and module boundaries represent different lexical scopes. It also must not be the default behavior.actionless commentedon Sep 2, 2016
do you mean handling each command's return code/output or smth else?
krader1961 commentedon Oct 6, 2016
Closing this as a duplicate of issue #510. While it is true this issue was originally broader than just dealing with unhandled command failures the fact is the discussion has been focused almost solely on the latter. So I'm going to close this as a duplicate of #510. Other topics, such as a bash
set -xequivalent for fish should be discussed in issues dealing with each specific feature (e.g., #3427).