tCorrect wrapping of cli argument arrays - tomb - the crypto undertaker
 (HTM) git clone git://parazyd.org/tomb.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 4ce8771e9905ce8b6b8f60ab96c92990e05a1416
 (DIR) parent 82e0533892050c79ee629b18d8c841b0d7c462c8
 (HTM) Author: Jaromil <jaromil@dyne.org>
       Date:   Fri, 14 Nov 2014 20:12:30 +0100
       
       Correct wrapping of cli argument arrays
       
       Fixes also piping to ssh for remote tomb commands
       This fix was suggested by @brianmay on #139
       
       Diffstat:
         M tomb                                |      10 +++++-----
       
       1 file changed, 5 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/tomb b/tomb
       t@@ -49,7 +49,7 @@ typeset TOMBEXEC=$0
        
        # Keep a reference of the original command line arguments
        typeset -a OLDARGS
       -for arg in ${argv}; do OLDARGS+=($arg); done
       +for arg in "${(@)argv}"; do OLDARGS+=("$arg"); done
        
        # Special command requirements
        typeset -a DD WIPE MKFS
       t@@ -418,7 +418,7 @@ EOF
                    _verbose "Escalating privileges using sudo-pwd."
                    sudo -S -v <<<`option_value --sudo-pwd`
                fi
       -        sudo "${TOMBEXEC}" -U ${UID} -G ${GID} -T ${TTY} "${(@)OLDARGS}"
       +        sudo "${TOMBEXEC}" -U "${UID}" -G "${GID}" -T "${TTY:-SSH_TTY}" "${(@)OLDARGS}"
                exit $?
            fi # are we root already
        
       t@@ -2425,7 +2425,7 @@ main() {
                done
            done
            local -a oldstar
       -    oldstar=($argv)
       +    oldstar=("${(@)argv}")
                #### detect early: useful for --optiion-parsing
            zparseopts -M -D -Adiscardme ${every_opts}
                if [[ -n ${(k)discardme[--option-parsing]} ]]; then
       t@@ -2450,7 +2450,7 @@ main() {
                _warning "There's no such command \"::1 subcommand::\"." $subcommand
                exitv=127 _failure "Please try -h for help."
            fi
       -    argv=(${oldstar})
       +    argv=("${(@)oldstar}")
            unset oldstar
        
            ### Parsing global + command-specific options
       t@@ -2665,7 +2665,7 @@ EOF
        
        # {{{ Run
        
       -main $@ || exit $?   # Prevent `tomb source tomb` from exiting
       +main "$@" || exit $?   # Prevent `tomb source tomb` from exiting
        
        # }}}