The issue is due to how the script test.sh is structured and how input/output is handled in Bash. Let's break it down:
adb shell exit:
adb shell session. If there is no active adb shell session, this command will fail silently (or with an error, depending on your environment).read test:
read command waits for user input from stdin (standard input).echo hey into the script (echo hey | ./test.sh), so the script receives hey as input for the read command.read command consumes the entire input (hey), but the script does not explicitly output anything after reading it.echo $test:
test, which was set by the read command.echo $test is not being captured or displayed in your terminal because the script's output is not being explicitly directed to stdout in a way that is visible in this context.hey) into the variable test, but the echo $test output is not being displayed because:
|), and the output of echo $test is not being passed back to the terminal.If you want the script to output the value of test when run with echo hey | ./test.sh, you need to ensure the script explicitly prints the output to stdout. For example:
bash#!/bin/bash adb shell exit read test echo "$test" # Explicitly print the value of $test
Now, running:
bashecho hey | ./test.sh
will output:
texthey
echo $test in a way that was visible when run via a pipe.read command consumed the input, but the script did not explicitly return or display the output.Vibe can make mistakes. Check answers. Learn more