On Thu, Feb 03, 2022 at 10:19:37AM -0700, Jeff Law wrote:
> > > Is getconf and expr length sufficiently portable?
> > > Can't you use
> > > echo "$all_dirs" | xargs mkdir -p
> > > instead?
> > 
> > Oh, even better!
> Definitely.  I suspect getconf wouldn't have worked across all the hosts we
> support.
> 
> 
> > 
> > Ready to be installed?
> Yes, this version is much better :-)

Looking at mkinstalldirs, there are comments like:
# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error.  This is a problem when calling mkinstalldirs
# from a parallel make.  We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
  '')
    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
      echo "mkdir -p -- $*"
      exec mkdir -p -- "$@"
    else
      # On NextStep and OpenStep, the 'mkdir' command does not
      # recognize any option.  It will interpret all options as
      # directories to create, and then abort because '.' already
      # exists.
      test -d ./-p && rmdir ./-p
      test -d ./--version && rmdir ./--version
    fi
    ;;

I guess we don't need thread safety as hopefully we don't run this from
multiple jobs concurrently, NextStep/OpenStep are probably long time dead,
but does mkdir -p work now everywhere?

        Jakub

Reply via email to