New answers tagged

1

libtrash is broken: For example, in helpers.c: char* make_absolute_path_from_dirfd_relpath(int dirfd, const char *arg_pathname) { char *abs_path = NULL; if (arg_pathname == NULL) { return NULL; } else if (arg_pathname[0] == '/' || dirfd == AT_FDCWD) { return arg_pathname; } else if (dirfd <= 0) { errno = ...


2

Command-line arguments are not at all the same thing as stdin; even commands that use both generally use them for different things. Take cat for example: echo foo bar | cat # outputs "foo bar" cat foo bar # looks for files named "foo" and "bar", and concatenates them (if found) If you look at most other commands that read from stdin, you'll ...


6

The commands that read stdin are almost all of the filter family, i.e. programs that transform a flow of text data to a transformed one. cat , sed, awk, gzip and even sh are good examples of such "filters". The cited commands, cp, mv and rm are definitely not filters but commands that do things with the arguments passed, here files or directories. The cd ...


2

The process substitution rawtopng <(tail myfile) fileout creates a pipe (just like tail myfile | rawtopng - fileout), and passes a name for the pipe to the program. On Linux, rawtopng will see a name like /dev/fd/42, and if it queries the file type, it'll be told that it's a pipe. No write to the filesystem is required (this is an anonymous pipe, not a ...


1

I think you're on the right track! <(tail myfile) will create an Anonymous Named Pipe, and is a type of Bash Process Substitution. Normally, this will pass /dev/fd/XX as the "filename", which is a file descriptor interface to the running process. From the examples in the linked documentation: bash$ wc <(cat /usr/share/dict/linux.words) 483523 ...


0

You can create a named pipe. Do something like mkfifo input to create the pipe. Start the program that you want to read the output of, and redirect the output to the pipe, aka myprog > input Then run your other command with input as the file. Note that pipes are one directional. The program will be able to read, but not to write.


6

It is impossible to have NUL bytes in command line arguments, so the question is what do you want to happen in case there are NUL bytes in the standard input. As you've noted, your candidate solution #1 runs the command multiple times in this case. That's not ideal. But there is no ideal solution that lets you handle true binary input. As I see it, your ...



Top 50 recent answers are included