Skip to content

Instantly share code, notes, and snippets.

View dm4web's full-sized avatar
:octocat:
Ni ban Kita no shima wa samuiii Hyakkoi-koi-koi, Atama buru buru, Aho baakaaaaa

Danila Molchanov dm4web

:octocat:
Ni ban Kita no shima wa samuiii Hyakkoi-koi-koi, Atama buru buru, Aho baakaaaaa
  • Saint-Petersburg
View GitHub Profile
@dm4web
dm4web / run-command.zsh
Created October 25, 2024 11:50 — forked from romkatv/run-command.zsh
Zsh function to run a command and capture its status, stdout and stderr
# Runs "$@" in a subshell with the caller's options, sets reply=(stdout stderr)
# and returns the status of the executed command. Both stdout and stderr are
# captured completely, including NUL bytes, incomplete UTF-8 characters and
# trailing LF, if any.
#
# Example:
#
# % zsh-run-command ls -d ~ /garbage
# % printf 'status: %s\nstdout: %s\nstderr: %s\n' $? "${(q+)reply[@]}"
# status: 2
@dm4web
dm4web / run-command.zsh
Created October 25, 2024 11:50 — forked from romkatv/run-command.zsh
Zsh function to run a command and capture its status, stdout and stderr
# Runs "$@" in a subshell with the caller's options, sets reply=(stdout stderr)
# and returns the status of the executed command. Both stdout and stderr are
# captured completely, including NUL bytes, incomplete UTF-8 characters and
# trailing LF, if any.
#
# Example:
#
# % zsh-run-command ls -d ~ /garbage
# % printf 'status: %s\nstdout: %s\nstderr: %s\n' $? "${(q+)reply[@]}"
# status: 2