Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Bash Process Substitution #4340

Closed
yash-fn opened this issue Mar 14, 2025 · 4 comments
Closed

Support Bash Process Substitution #4340

yash-fn opened this issue Mar 14, 2025 · 4 comments
Assignees

Comments

@yash-fn
Copy link

yash-fn commented Mar 14, 2025

the --filelist=FILE option is great to bypass command line length limits if a lot of files like for the dictionary training thing. But instead of requiring physical file which is annoying to have lying around, bash process substituitons are great! Something like:

--filelist=<(find . -type f -print)

but this won't work because zstd says:

zstd: error reading /dev/fd/63

. Seems zstd does some sort of check that required FILE to actually be a text file.

@Cyan4973
Copy link
Contributor

Cyan4973 commented Mar 25, 2025

The current implementation that reads the file list and extracts the filenames
requires knowledge of the file size for buffer allocation.
Such information is unavailable in the case of named pipe, which process substitution employs.

Supporting this use case will first require a rewrite of the function that extract the filenames.

@tansy
Copy link

tansy commented Mar 26, 2025

Of all standard compressors the most reasonable response presented lzip.

$ gzip -k <(cat a.txt)
gzip: /dev/fd/63: Too many levels of symbolic links
$ bzip2 -k <(cat a.txt)
bzip2: Input file /dev/fd/63 is not a normal file.
$ zstd -k <(cat a.txt)
zstd: /dev/fd/63.zst: No such file or directory
$ lzip -k <(cat a.txt)
lzip: /dev/fd/63: Input file is not a regular file,
  and neither '-c' nor '-o' were specified.
$ lzip -c <(cat a.txt) > a.txt.lz

Maybe similar, crear, descriptive, though brief message would suffice.

@Cyan4973
Copy link
Contributor

Cyan4973 commented Mar 27, 2025

The issue seems that it's not possible to just write a *.zst output file into /dev/fd/.

If an output was specified, it would work :

./zstd <(cat tmp) -o tmp.zst -f
/dev/fd/11           : 32.10%   (  64.0 KiB =>   20.5 KiB, tmp.zst)

Point taken that, when no output is provided and the operation fails,
the error message is quite bland and does not describe accurately the situation.
It's currently provided by the local C runtime, via strerror(),
and quite frankly, I would have expected something like Permission denied instead.

Another solution would be statically decide a message, like zstd: /dev/fd/63.zst: Cannot open file,
that would be more accurate in this specific case,
but would also lose the ability of strerror() to provide a wider range of error messages for other scenarios.\

edit: new error message, more explicit for process substitution, at #4349:

./zstd <(cat tmp)
zstd: /dev/fd/11.zst: No such file or directory
When using process substitution (<(...)), specify an output destination with -o or -c.

@tansy
Copy link

tansy commented Mar 27, 2025

The process substitution is essentially a pipe so these are not regular files.
Instead of making special case for it, it would better state the fact that it's not a regular file and no output was specified.

zstd: /dev/fd/63: Not a regular file
and no output specified (try -c or -o)

Or something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants