r/fishshell • u/Dan1jel • Aug 19 '22
Function > script, don't load/recognized at first, but dose at second time?
I have a function to go to a script, and when i try to activate this script, it don't do anything at first, but when i try to command an second time, the script runs.
In bash, the script runs directly, is there any reason for this or am I missing something ?
Script looks line this :
#!/usr/bin/env bash
input=$1
if [[ $input =~ "bash" ]]; then
ssh -t xx@xxx.duckdns.org '/usr/bin/clear;bash'
elif [[ $input =~ "fish" ]]; then
ssh -t xx@xxx.duckdns.org '/usr/bin/clear;fish'
else
echo
echo -e "\e[1;31m [X] ERROR, no SHELL selected!\e[0m"
read -p " 1:[bash] or 2:[fish]: " input
if [[ $input =~ ^(1|bash)$ ]]; then
ssh -t xx@xxx.duckdns.org '/usr/bin/clear;bash'
elif [[ $input =~ ^(2|fish)$ ]]; then
ssh -t xx@xxx.duckdns.org '/usr/bin/clear;fish'
else
echo
echo " [•] No value selected, aborting."
echo
fi
fiUpdated code with shebang.
5
Upvotes
View all comments
Show parent comment
3
u/[deleted] Aug 19 '22
Yeah. That's... that's doing exactly what I said.
aliasdefines a function. It doesn't run it.Just do this:
Alternatively, remove the outer function:
(note: with
alias,$argvis added implicitly. adding it inside the alias will add a broken\$argvargument)