I have written 5 shell scripts ever, and only 1 of them has been more complex than "I want to alias this single command"
I can't imagine being an actual shell dev
I have written 5 shell scripts ever, and only 1 of them has been more complex than "I want to alias this single command"
I can't imagine being an actual shell dev
It really isn't bad especially if you use ash
I was never a fan of set -e. I prefer to do my own error handling. But, I never understood why pipefail wasn't the default. A failure is a failure. I would like to know about it!
IIRC if you pipe something do head it will stop reading after some lines and close the pipe, leading to a pipe fail even if everything works correctly
Yeah, I had a silly hack for that. I don't remember what it was. It's been 3-4 years since I wrote bash for a living. While not perfect, I still need to know if a pipeline command failed. Continuing a script after an invisible error, in many cases, could have been catastrophic.
just use python instead.
subprocess.run(), to call to system utilspathlib.Path for file paths and reading/writing to filesshutil.which() to resolve utilities from your Path env varHere's an example of some python i use to launch vscode (and terminals, but that requires dbus)
from pathlib import Path
from shutil import which
from subprocess import run
def _run(cmds: list[str], cwd=None):
p = run(cmds, cwd=cwd)
# raises an error if return code is non-zero
p.check_returncode()
return p
VSCODE = which('code')
SUDO = which('sudo')
DOCKER = which('docker')
proj_dir = Path('/path/to/repo')
docker_compose = proj_dir / 'docker/'
windows = [
proj_dir / 'code',
proj_dir / 'more_code',
proj_dir / 'even_more_code/subfolder',
]
for w in windows:
_run([VSCODE, w])
_run([SUDO, DOCKER, 'compose', 'up', '-d'], cwd=docker_compose)
Or Rust. Use Command::new() for system commands and Path::new() for paths.
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
sudo in Windows.Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.