Ah, this clarifies the issue! The error message indicates that tgui-bash expects a file path as an argument, not the script content directly via heredoc or stdin. It’s not designed to read a script from stdin or a heredoc; it wants you to pass a file path containing the script.
Correct Approach: Use a Temporary File
Since tgui-bash requires a file path, you should:
Write your script to a temporary file.
Pass the path of that file to tgui-bash.
Optionally, delete the file afterward.
Example in .bashrc:
bash
my_test() {
# Create a temporary file
tmpfile=$(mktemp)
# Write the script to the temp file
cat > "$tmpfile" <<'EOF'
set -u
declare -A aparams=()
declare -a activity=()
tg_activity_new aparams activity
aid="${activity[0]}"
echo "Activity ID: $aid"
EOF
# Pass the file to tgui-bash
tgui-bash "$tmpfile"
# Clean up
rm -f "$tmpfile"
}
How to Use:
After adding this to your .bashrc, reload it:
bash
source ~/.bashrc
Run the function:
bash
my_test
Alternative: Use Process Substitution
If you don’t want to create a temporary file, you can use process substitution (Bash feature) to pass a file-like object:
bash
my_test() {
tgui-bash <(cat <<'EOF'
set -u
declare -A aparams=()
declare -a activity=()
tg_activity_new aparams activity
aid="${activity[0]}"
echo "Activity ID: $aid"
EOF
)
}
Why This Works
tgui-bash is designed to run shell scripts stored in files, not stdin or heredocs.
Using a temporary file or process substitution satisfies this requirement.
Apr 10, 1:10pm
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.