azet/community_bash_style_guide

Better Multiline Pipe

ldo opened this issue · 4 comments

ldo commented

Instead of

ls ${long_list_of_parameters}	\
    | grep ${foo}	            \
    | grep -v grep	            \
    | pgrep	                    \
    | wc -l	                    \
    | sort	                    \
    | uniq

how about

ls ${long_list_of_parameters} |
    grep ${foo} |
    grep -v grep |
    pgrep |
    wc -l |
    sort |
    uniq

which is less cluttered?

@ldo I like your approach. I've not used pipes for linebreaks. Does one see drawbacks?

Nitpicking: I'd prefer to have a "table" style format

ls ${long_list_of_parameters} |
    grep ${foo}               |
    grep -v grep              |
    pgrep                     |
    wc -l                     |
    sort                      |
    uniq
ldo commented

Lining things up in columns ... I have better things to do with my time.

It's a styleguide and should be understandable and pretty. Why don't spend the time creating a PR? :-)

azet commented

To be honest: this can be debated but I like the original/current recommendation (which is also used in other style guides), it's clearer from/to where the pipe flows.