Skip to main content
The 2024 Developer Survey results are live! See the results
replaced http://apple.stackexchange.com/ with https://apple.stackexchange.com/
Source Link

You are correct that your two first on-liners should be working according to bash process substitution semantics. In mymy testingtesting (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

linked to test results in comments
Source Link
kopischke
  • 5.2k
  • 23
  • 33

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testingmy testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

– if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

Minor rephrasing.
Source Link
kopischke
  • 5.2k
  • 23
  • 33

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it seemslooks like you aremay be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

it seems likeif source is onea command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it seems like you are running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

it seems like source is one command that has difficulties with this (at least in bash 3.2).

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

You are correct that your two first on-liners should be working according to bash process substitution semantics. In my testing (bash 3.2 on OS X 10.8.2), the second one does, while the first one does not.

In the case of your first one-liner, it looks like you may be running into one of the limitations of process substitution. Quoting the Wikipedia page on process substitution:

Process substitution has some limitations: the “files” created are not seekable, which means the process reading or writing to the file cannot perform random access; it must read or write once from start to finish. Programs that explicitly check the type of a file before opening it may refuse to work with process substitution, because the “file” resulting from process substitution is not a regular file.

if source is a command that has difficulties with this (at least in bash 3.2), that would explain its failure to work with process substitution.

The second one-liner possibly just looks like it fails because it executes the code in a subshell rather than sourcing it. If you are expecting it to set aliases and functions, this won’t work, as these do not carry over to the parent shell when defined in a subshell.

The third one-liner doesn’t work because source does not process stdin – only files (see bash man page).

Minor rephrasing.
Source Link
kopischke
  • 5.2k
  • 23
  • 33
Loading
Tried to clarify the different apparent failure reasons for the three one-liners indicated.
Source Link
kopischke
  • 5.2k
  • 23
  • 33
Loading
Amended text in reaction to comment by @patrix
Source Link
kopischke
  • 5.2k
  • 23
  • 33
Loading
Source Link
kopischke
  • 5.2k
  • 23
  • 33
Loading