Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Equivalent of bash set -e #3415

Copy link
Copy link
@pauldambra

Description

@pauldambra
Issue body actions

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

No one assigned

    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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.