Bug 679

Summary: sudo -i ignores empty arguments
Product: Sudo Reporter: morloch
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: ASSIGNED ---    
Severity: low    
Priority: low    
Version: 1.8.9   
Hardware: PC   
OS: Linux   

Description morloch 2015-01-11 16:21:26 MST
Here is an example bash script that I would like to run using `sudo -i`:

    #!/bin/bash
    
    echo "arg 1: $1"
    echo "arg 2: $2"

When I run this command normally with one empty argument, it runs as expected:

    $ /tmp/args.sh "" two
    arg 1:
    arg 2: two

With plain sudo, I get the expected result:

    $ sudo /tmp/args.sh "" two
    arg 1:
    arg 2: two

However if I use `-i` (to pick up the user's shell and login scripts), suddenly the first argument disappears:

    $ sudo -i /tmp/args.sh "" two
    arg 1: two
    arg 2:

Current workarounds are:

* writing `/tmp/args.sh "" two` to a file and then executing that with `sudo -i`

* run: sudo -i bash -c '/tmp/args.sh "" two'

Stack Overflow: http://stackoverflow.com/questions/27892812/passing-empty-arguments-to-sudo-i