[Top][All Lists]

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

Re: make install failed; dump core in mkdir

From: Greg Wooledge
Subject: Re: make install failed; dump core in mkdir
Date: Mon, 2 Dec 2019 08:51:27 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

On Sun, Dec 01, 2019 at 03:20:54PM +0000, George R Goffe via Bug reports for 
the GNU Bourne Again SHell wrote:
> mkdir ()
> { 
> dirs="$@";
> for dir in $dirs;
> do
> /bin/mkdir -p "$dir";
> done
> }

This function is severely flawed.  I believe this is what you wanted:

mkdir() {
  command mkdir -p "$@"

Your function smashes an array into a string (using first-char-of-IFS
as a delimiter), then breaks up that string using IFS, which may or
may not reproduce the original array.  There's no reason for that
double conversion at all.  On top of that, your function messes with
two variables that aren't local to it.

Either of those flaws could conceivably break a script that uses this
function unexpectedly.

Another way your function could break a script is if the script is
*counting* on mkdir to perform the atomic make-or-fail-trying
operation (no -p option), for example when trying to create a directory
as a form of mutual exclusion locking.  Adding -p breaks that usage
of mkdir.  Granted, I find it unlikely that a "make install" operation
would be using mkdir in that highly specific way.  But just in general,
altering the basic operations of the core shell utilities is unwise.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]