#1036827 coreutils: split: --additional-suffix= doesn't always find the /, but also shouldn't look for it?

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
наб
Date:
2023-05-27 15:39:02 UTC
Severity:
normal
#1036827#5
Date:
2023-05-27 12:54:10 UTC
From:
To:
Dear Maintainer,
  $ echo | split --additional-suffix=asd/
  split: xaaasd/: Is a directory
  $ echo | split --additional-suffix=asd/asd/
  split: invalid suffix ‘asd/asd/’, contains directory separator
  Try 'split --help' for more information.
  $ echo | split --additional-suffix=asd/asd
  split: invalid suffix ‘asd/asd’, contains directory separator
  Try 'split --help' for more information.
  $ echo | split --additional-suffix=/
  split: invalid suffix ‘/’, contains directory separator
  Try 'split --help' for more information.

Also, I don't really see a reason to reject slashes in there anyway?
Forbidding
  $ printf abcd > a
  $ printf ABCD > A
  $ mkdir 0 1 2 3
  $ split -b1 --additional-suffix=/a -da1 a ''
  $ split -b1 --additional-suffix=/A -da1 A ''
  $ find
  .
  ./0
  ./0/A
  ./0/a
  ./3
  ./3/A
  ./3/a
  ./2
  ./2/A
  ./2/a
  ./1
  ./1/A
  ./1/a
  ./A
  ./a
  $ grep . ?/*
  0/a:a
  0/A:A
  1/a:b
  1/A:B
  2/a:c
  2/A:C
  3/a:d
  3/A:D
seems relatively pointless.

Best,
наб

#1036827#10
Date:
2023-05-27 15:35:59 UTC
From:
To:

Yes we should fix the inconsistency here at least.
The "slash detection" logic was copied from mktemp,
so we'll need to look at that too.

$ mktemp --tmpdir=. --suffix=a/
mktemp: failed to create file via template ‘./tmp.XXXXXXXXXXa/’: Is a directory
$ mktemp --suffix=a/
mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXXa/’: Is a directory

Though mktemp can create dirs, so perhaps the trailing / is allowed for that?
Though docs say a slash isn't allowed in suffix, so it's probably an oversight.

Note templates for mktemp can contain dirs,
so it's only the combo of dirs with /tmp
or sub dirs in --suffix that are disallowed,
which makes sense for mktemp.

For split it may well be simplest to just remove the restriction.

cheers,
Pádraig