How to convert this zsh function to shell?

I have this function that works fine in zsh, but I want to convert it to a shell, and I cannot get it to work.

function ogf () {
  echo "Cloning, your editor will open when clone has completed..."
  source <(TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts "$1")
}
+1
source share
1 answer

First of all, since the syntax of fish is different from zsh, you also need to change the output clone_git_fileto source.

For example, if clone_git_fileit looks something like this:

#!/bin/bash
echo "FOO=$TARGET_DIRECTORY"
echo "BAR=$2"

you need to change it to fish syntax.

#!/bin/bash
echo "set -gx FOO $TARGET_DIRECTORY"
echo "set -gx BAR $2"

Now here is the function ogf()and sample code for the fish:

function ogf
  echo "Cloning, your editor will open when clone has completed..."
  source (env TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts $argv[1] | psub)
end

ogf MY_ARGUMENT
echo "FOO is $FOO"
echo "BAR is $BAR"

Running this code with fish:

FOO is /home/MY_USER/students
BAR is MY_ARGUMENT
+2
source

Source: https://habr.com/ru/post/1668988/


All Articles