f in $(ls *.m3u) ^---------^ SC2045: Iterating over ls output is fragile. Use globs. ^-- SC2035: Use ./*glob* or -- *glob* so names with dashes won't become In ./sample.sh line 5: grep -qi hq.*mp3 $f \ ^-----^ SC2062: Quote the grep pattern so the shell won't interpret it. ^-- SC2086: Double quote to prevent globbing and word splitting. Did you mean: grep -qi hq.*mp3 "$f" \ In ./sample.sh line 6: && echo -e 'Playlist $f contains a HQ file in mp3 format' ^-- SC2039: In POSIX sh, echo flags are undefined. ^ SC2016 E i d 't d i i l t d bl t 9 / 21
script with several problems for f in $(ls *.m3u) do grep -qi hq.*mp3 $f \ && echo -e 'Playlist $f contains a HQ file in mp3 format' done #!/bin/sh ## Example: a typical script with several problems for f in *.m3u do [ -e "$f" ] || break grep -qi "hq.*mp3" "$f" \ && echo "Playlist $f contains a HQ file in mp3 format" done 11 / 21
既定値は bash -s shell, –shell=shell Specify Bourne shell dialect. Valid values are sh, bash, dash and ksh. The default is to use the file's shebang, or bash if the target shell can't be determined. 14 / 21