Skip to main content
Became Hot Network Question
edited tags
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

For what purpose does read"read" exit 1 when EOF is encountered?

The bash man page says the following about the readread builtin:

The exit status is zero, unless end-of-file is encountered

This recently bit me because I had the -e option set and was using the following code:

read -rd '' json <<EOF
{
    "foo":"bar"
}
EOF

I just don't understand why it would be desirable to exit non successfully in this scenario. In what situation would this be useful?

For what purpose does read exit 1 when EOF is encountered?

The bash man page says the following about the read builtin:

The exit status is zero, unless end-of-file is encountered

This recently bit me because I had the -e option set and was using the following code:

read -rd '' json <<EOF
{
    "foo":"bar"
}
EOF

I just don't understand why it would be desirable to exit non successfully in this scenario. In what situation would this be useful?

For what purpose does "read" exit 1 when EOF is encountered?

The bash man page says the following about the read builtin:

The exit status is zero, unless end-of-file is encountered

This recently bit me because I had the -e option set and was using the following code:

read -rd '' json <<EOF
{
    "foo":"bar"
}
EOF

I just don't understand why it would be desirable to exit non successfully in this scenario. In what situation would this be useful?

Source Link
jesse_b
  • 41.5k
  • 14
  • 108
  • 162

For what purpose does read exit 1 when EOF is encountered?

The bash man page says the following about the read builtin:

The exit status is zero, unless end-of-file is encountered

This recently bit me because I had the -e option set and was using the following code:

read -rd '' json <<EOF
{
    "foo":"bar"
}
EOF

I just don't understand why it would be desirable to exit non successfully in this scenario. In what situation would this be useful?