tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Proposal to add /usr/bin/shquote



I often find the need, in shell scripts, to escape arguments to be
passed to other shell commands.  I'd like to add a /usr/bin/shquote
command as a simple wrapper around shquotev(3) to do this.

Sample usage:

        $ shquote foo bar
        'foo' 'bar'
        $ set -- -foo bar "arg with spaces" "don't panic" '"Help!"'
        $ echo "$#"
        5
        $ echo "$4"
        don't panic
        $ list="$( shquote "$@" )"
        shquote: unknown option -- f
        Usage: shquote [--] [arg ...]
        $ list="$( shquote -- "$@" )"
        $ echo "$list"
        '-foo' 'bar' 'arg with spaces' 'don'\''t panic' '"Help!"'
        $ eval "set -- $list"
        $ echo "$#"
        5
        $ echo "$4"
        don't panic

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index