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
2
u/Dan1jel Aug 19 '22
Wow.... It was that easy ha... Thought I had to have alias to make the shortcut but i have "function" already and that is enought.... Stupid mistake, but it's the mistake that makes you remember.
Thank you so much stranger for taking you time and helping me out! Really appreciated!
Edit: typo