Bash 脚本转换为鱼

Bash script conversion to fish

我正在尝试将此脚本转换为鱼: https://github.com/masahide/OmniSSHAgent/blob/main/hack/ubuntu-bash.setup.sh

这是我目前的进度:

set OMNISOCATCMD $HOME/omni-socat/omni-socat.exe
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock

function __get_omnisocat
  echo "Get omni-socat.exe"
  curl https://github.com/masahide/OmniSSHAgent/releases/latest/download/omni-socat.zip \
      -sLo omni-socat.zip
  unzip -o omni-socat.zip -d (dirname $OMNISOCATCMD)
  rm omni-socat.zip
end

function __get_socat
  echo "Install socat"
  sudo apt -y install socat
end


function setup_omnisocat
  [[ -f $OMNISOCATCMD ]]  || __get_omnisocat
  [[ -f /usr/bin/socat ]] || __get_socat
  
  ss -a | grep -q $SSH_AUTH_SOCK
  [[ $status -ne 0 ]]  || return

  rm -f $SSH_AUTH_SOCK
  
  (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK; fork EXEC:"$OMNISOCATCMD"; nofork &) >/dev/null 2>&1
end

setup_omnisocat

除了最后一个函数中的主命令替换外,应该完全转换:

(setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK; fork EXEC:"$OMNISOCATCMD"; nofork &) >/dev/null 2>&1

引发此错误:

omni-socat/ubuntu-fish.setup.fish (line 27): Command substitutions not allowed
  (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK; fork EXEC:"$OMNISOCATCMD"; nofork &) >/dev/null 2>&1
  ^
from sourcing file omni-socat/ubuntu-fish.setup.fish
.: Error while reading file 'omni-socat/ubuntu-fish.setup.fish'

而且我不明白如何转换它。 你能帮助我吗? 谢谢

找到正确的转换方式(感谢@masahide:https://github.com/masahide/OmniSSHAgent/issues/16#issuecomment-1107446991):

setsid nohup socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/omni-socat/omni-socat.exe" >/dev/null 2>&1 & disown