···490490}
491491492492493493-# Utility function: return the base name of the given path, with the
493493+# Utility function: echo the base name of the given path, with the
494494# prefix `HASH-' removed, if present.
495495stripHash() {
496496- strippedName=$(basename $1);
496496+ local strippedName="$(basename "$1")";
497497 if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then
498498 echo "$strippedName" | cut -c34-
499499+ else
500500+ echo "$strippedName"
499501 fi
500502}
501503···506508507509 if [ -d "$fn" ]; then
508510509509- stripHash "$fn"
510510-511511 # We can't preserve hardlinks because they may have been
512512 # introduced by store optimization, which might break things
513513 # in the build.
514514- cp -pr --reflink=auto "$fn" $strippedName
514514+ cp -pr --reflink=auto "$fn" "$(stripHash "$fn")"
515515516516 else
517517