[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bin/live-update-initramfs: dirname / basename fixes



>>>>> Daniel Baumann <daniel.baumann@progress-technologies.net> writes:

 > i've fixed both in git, in a somewhat less complicated way though,
 > thanks.

	Even if wc(1) is for some reason deemed necessary, ls(1) is
	useless in this case.  Roughly speaking, the difference between
	$ ls foo* and $ printf %s\\n foo* is the same as between
	$ cat foo | grep bar and $ grep bar foo.  (To note is that
	printf is built into both Bash and Dash.)

	As for the second change, the use of the ${VAR#PATTERN}
	construct: is POSIX [1] (and implemented by Bash, Dash, and
	Busybox' Ash), saves two forks (basename(1), sed(1)), /and/
	makes the code more concise.  So, I'd rather recommend doing it
	that way.

	However, contrary to my previous patch, it's the ${VAR##PATTERN}
	(“longest match”) form that should be used.

	TIA.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02

-- 
FSF associate member #7257


Reply to: