News for hackers. Stuff that matters.
Re:Bash Pitfalls by cmma on Sunday August 16, 2015 @08:46PM (#10070881)
> You say you can do "some_command * .mp3"...true if either a) your command is safe to run with garbage input or b) you know that you have >= one file and no whitespace in filenames.

Globbing preserves whitespace. It's up to the target function to discard it, by forgetting to quote arguments.

    example1() {
        [ $# -eq 0 ] && return
        echo "$1"
        shift
        example1 "$@"
    }

    example2() {
        for arg in "$@"; do
            echo "$arg"
        done
    }

    touch 1 "2 3" 4
    example1 *
    example2 *

    # both examples print:
    #     1
    #     2 3
    #     4

There are no comments on this comment yet.