Skip to main content
added 26 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Rather than taking the string as a command line argument, you may simply use cat to read the script's standard input:

printf '%s\n' "$foo"
if [ "$bar" = "-" ]; then
    # assume data is on standard input
    cat
else
    print '%s\n' "$bar"
fi

Rather than taking the string as a command line argument, you may simply use cat to read the script's standard input:

if [ "$bar" = "-" ]; then
    # assume data is on standard input
    cat
else
    print '%s\n' "$bar"
fi

Rather than taking the string as a command line argument, you may simply use cat to read the script's standard input:

printf '%s\n' "$foo"
if [ "$bar" = "-" ]; then
    # assume data is on standard input
    cat
else
    print '%s\n' "$bar"
fi
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Rather than taking the string as a command line argument, you may simply use cat to read the script's standard input:

if [ "$bar" = "-" ]; then
    # assume data is on standard input
    cat
else
    print '%s\n' "$bar"
fi