Home > Net >  Fix the "-e" is deprecated warning with gnome-terminal
Fix the "-e" is deprecated warning with gnome-terminal

Time:05-11

I have the below script.

#!/bin/bash

# Run pando-app services
cd abc-app/packages/auth-service

tab=" --tab"
options_1=()
options_2=()

cmd_1[1]="yarn start"
cmd_1[2]="cd ../../api/shipper; yarn start:shipper"
cmd_1[3]="cd ../../frontend/shipper; yarn dev"

cmd_2[1]="yarn start:procure-app"
cmd_2[2]="yarn start:procure-worker"
cmd_2[3]="yarn start:mail-worker"
cmd_2[4]="yarn start:transporter"
cmd_2[5]="cd ../frontend/shipper; yarn dev"
cmd_2[6]="cd ../frontend/transporter; yarn dev"


for i in 1 2 3; do
options_1 =($tab -e "bash -c '${cmd_1[i]} ; bash'" )
done

for j in 1 2 3 4 5 6; do
options_2 =($tab -e "bash -c '${cmd_2[j]} ; bash'" )
done

gnome-terminal "${options_1[@]}"

cd
cd Documents/Code/abc-procure

gnome-terminal "${options_2[@]}"

When I run the script using ./startServices.sh, its runs as expected but with the below warnings

# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.

I see that's just a syntax change I need to do, but not sure how to apply and make it work.

CodePudding user response:

As the message says, you should use -- to separate the options from the command to execute:

for i in 1 2 3; do
    options_1 =("$tab" -- bash -c "${cmd_1[i]} ; bash" )
done

Also, you shouldn't put a space at the beginning of the value of $tab. Use

tab="--tab"

CodePudding user response:

You need something like

for i in 1 2 3; do
    gnome-terminal $tab -- bash -c "${cmd_1[i]} ; bash"
done
  • Related