Skip to content

Instantly share code, notes, and snippets.

@konsolebox
Last active March 18, 2026 12:41
Show Gist options
  • Select an option

  • Save konsolebox/71c7daed50a1d56da9252bfc9da9f3b3 to your computer and use it in GitHub Desktop.

Select an option

Save konsolebox/71c7daed50a1d56da9252bfc9da9f3b3 to your computer and use it in GitHub Desktop.
function get_command_string {
local string= q
for __; do
printf -v q %q "$__"
if [[ $q == "$__" ]]; then
string+=" $__"
elif [[ $__ == *\'* ]]; then
string+=" $q"
else
string+=" '$__'"
fi
done
__=${string# }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment