Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: make install failed; dump core in mkdir Date: Mon, 2 Dec 2019 08:51:27 -0500 Lines: 33 Approved: bug-bash@gnu.org Message-ID: References: <742858147.7229097.1575213654608.ref@mail.yahoo.com> <742858147.7229097.1575213654608@mail.yahoo.com> <20191202135127.GS851@eeg.ccf.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1575294720 13192 209.51.188.17 (2 Dec 2019 13:52:00 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org Mail-Followup-To: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: <742858147.7229097.1575213654608@mail.yahoo.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20191202135127.GS851@eeg.ccf.org> X-Mailman-Original-References: <742858147.7229097.1575213654608.ref@mail.yahoo.com> <742858147.7229097.1575213654608@mail.yahoo.com> Xref: csiph.com gnu.bash.bug:15683 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.