-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use the correct quote/escape for the context
/ref https://github.com/bevry/dorothy/actions/runs/11512899768 also fix `echo-regexp` including `stdinargs.bash` when it didn't need to
- Loading branch information
Showing
18 changed files
with
209 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
function echo_escape_bash() ( | ||
source "$DOROTHY/sources/stdinargs.bash" | ||
|
||
# ===================================== | ||
# Arguments | ||
|
||
function help { | ||
cat <<-EOF >/dev/stderr | ||
ABOUT: | ||
Escape the <...input> for usage inside bash. | ||
USAGE: | ||
echo-escape-bash [...options] [--] ...<input> | ||
echo-lines ...<input> | echo-escape-bash [...options] | ||
OPTIONS: | ||
$(stdinargs_options_help --) | ||
EOF | ||
return 22 # EINVAL 22 Invalid argument | ||
} | ||
|
||
# ===================================== | ||
# Action | ||
|
||
# we could use @Q for this, but it is strange, so just use %q\n | ||
# bash-5.2$ printf '%q\n' " a'" | ||
# \ a\' | ||
# bash-5.2$ b=\ a\' | ||
# bash-5.2$ echo "[$b]" | ||
# [ a'] | ||
# bash-5.2$ echo "${b@Q}" | ||
# ' a'\''' | ||
|
||
function on_input { | ||
printf '%q\n' "$@" | ||
} | ||
|
||
stdinargs "$@" | ||
) | ||
|
||
# fire if invoked standalone | ||
if test "$0" = "${BASH_SOURCE[0]}"; then | ||
echo_escape_bash "$@" | ||
fi |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.