News for hackers. Stuff that matters.
Re:Bash Pitfalls by hyperpape on Sunday August 16, 2015 @03:47PM (#10070026)
There are two points here. 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. Both of these are often reasonable assumptions, but I want a general purpose solution that doesn't have more edge cases than it has to.

The mental model of bash is "this text expands to this text like so, which means x haappens." The model I want is "I'm gonna do x to each of these files."

As for the 23 commands, my attitude is that this is usually either ~19 too many, or infinitely too few.

I acknowledge that maybe the way of doing things will start to make sense at some point, but it hasn't happened yet, and I find trying to climb the hill of understanding the shell to be a joyless experience.

Re:Bash Pitfalls by a3n on Sunday August 16, 2015 @03:58PM (#10070056)
> As for the 23 commands, my attitude is that this is usually either ~19 too many, or infinitely too few.

As recently seen on HN: http://www.cs.yale.edu/homes/perlis-alan/quotes.html

11. If you have a procedure with ten parameters, you probably missed some.

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