4 ms·
If only it had `&&`
by pitaj 9y ago
If only it had `&&`
- seabrookmx 9y ago100x yes. The amount of times per day I do something along the lines of git add --all && git commend (commend being an alias for "commit --amend --no-edit") or npm install && npm prune && npm run watch This is the main reason I use git-bash as my primary terminal whenever I'm working on Windows.
- WorldMaker 9y agoSemicolon works, though doesn't have the quit/shortcutting on exit code semantics. There are some community tools to fake it a little better (Get-ExitBoolean). Also, a big GitHub issue tracking it: https://github.com/PowerShell/PowerShell/issues/3241 https://github.com/PowerShell/PowerShell/issues/3241
- darrenf 9y ago> Semicolon works, though doesn't have the quit/shortcutting on exit code semantics. I would say it's a little more than semantics. Consider cd /some/dir/with/a/typo && some_destructive_cmd . vs the semi-colon equivalent.
- WorldMaker 9y agoNo, absolutely, there are many cases where semicolon is a bad replacement and a more suitable arrangement found. I'm just speaking to a lot of the "quick one line scripts" that aren't dangerous, such at the parent suggested. Things like `npm install && npm prune` are fine as `npm install; npm prune`. It may "waste" cycles in the rare case of a failed install, but it isn't dangerous. I agree though, a good short-circuiting Boolean operator would be nice.
- tuan 9y agoOn Windows I use `;` to chain commands.
- coldacid 9y agoIt's not the same at all. `&&` only continues the chain if the previous command exited successfully (i.e. exit code is 0) whereas `;` always continues.
- ygra 9y agoThere is -and, but it eats output, so yeah, that's a bit annoying.
- ZenoArrow 9y ago$ErrorActionPreference="Stop" You're welcome.