Skip to main content
Tweeted twitter.com/StackUnix/status/830209605527535616
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Source Link
jirinovo
  • 185
  • 1
  • 6

How is stdin handled in this bash script?

I have a bash script (named opsin) which only manages the calling of Java binary. All arguments are forwarded with ${@:1} to Java binary.

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
java -jar $DIR/../bin-java/opsin/opsin.jar ${@:1}

This binary, opsin.jar, also accepts stdin so you can do

echo "abcd" | java -jar opsin.jar

But I can do the same with bash script above:

echo "abcd" | opsin

How is the stdin passed to

java -jar $DIR/../bin-java/opsin/opsin.jar ${@:1}

in bash script?