How to write function in bash for reuse shell commands inside using osascript?

35 Views Asked by At

I want to get rid of duplicates, but get the errors: 178:186: syntax error: A “"” can’t go after this identifier. (-2740) 133:134: syntax error: Expected expression but found unknown token. (-2741)

execute_commands() {
local command = "$1"
osascript <<EOF
    tell application "iTerm" to \
        tell the last session of current tab of current window to \
        write text $command
EOF
}

# function call
execute_commands "cd \"$PROJECT_PATH\"/frontend && npm run dev"

I tried to fix it in different ways, nothing works.

0

There are 0 best solutions below