Last active
August 6, 2021 03:05
-
-
Save jeffguorg/51a129a04bc9e11fb05731e94e8f2aa7 to your computer and use it in GitHub Desktop.
inplace function in zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
inplace() { | |
COMMAND="$1" | |
FILEPATH="$2" | |
set -x | |
OUTPUT="$(bash -c "${COMMAND} '${FILEPATH}'")" | |
RET=$? | |
if [ $RET -eq 0 ]; then | |
echo -n "$OUTPUT" >! "${FILEPATH}" | |
else | |
echo -n "$OUTPUT" | |
return $RET | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if i'm to prettify all the xml documents in current directory, imma run this command: