-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Languageparser, language semanticsparser, language semantics
Milestone
Description
I asked this question on twitter and it was suggested I post here.
Many people consider it good practice to start a bash script.
#! /bin/bash
set -eu
set -e tells the script to stop on first error
set -u tells the script to not allow undeclared variables
Although not everyone agrees
I think set -u and Set-StrictMode -Version 1.0 are equivalent.
I just wrote a set of Powershell scripts for managing an elasticsearch server. Then a few top-level scripts to tie them together.
It would have been really useful to be able to write something equivalent to...
set -e
$someValue = .\server-task-1.ps1
.\server-task-2.ps1 -using $someValue
.\task-that-requires-everything-else-suceeded.ps1
... but I couldn't find how to and ended up with something more like...
$someValue = .\server-task-1.ps1
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
.\server-task-2.ps1 -using $someValue
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
.\task-that-requires-everything-else-suceeded.ps1
if ($LastExitCode -ne 0) {
exit $LastExitCode
}
Apologies if this is already possible and I've missed it...
joandrsn, chrisalbrecht, ForNeVeR, felixfbecker, ZeekoZhu and 34 more
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Languageparser, language semanticsparser, language semantics