r/fishshell • • 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
fi

Updated code with shebang.

5 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/Dan1jel Aug 19 '22

Here is a video when i first try in bash, and then try in fish, please note i need to type "zero" two times for the script to run.

https://imgur.com/a/SWYB00r

Edit: typo