Bash: Script Calling Gnome Terminal Leads To Child Process Error?

I'm trying to have a script open a new terminal window, and then call another script in that terminal.

I'm getting the error:

There was an error creating the child process for this terminal

I believe it has something to do with the calling script trying to run the child processes.

I've tried the --x option in gnome-terminal. It's not working. I'm sure there is a way to tell Terminal to execute commands in the new Terminal. I just can't seem to find it in the documentation anywhere.

Anyone run into this and have a fix?

Ref problem code: Line 57, 58:

sudo gnome-terminal -x --window --wait --tab --active --title="$1" --geometry=120X60 \
--working-directory="$code_directory"  --command "$file_path"

Script in full context:

#!/bin/bash
# Runs last modified script in new Terminal window tab in dev qube.

# Global vars
qube_name='dev'
code_directory='/home/user/Documents/'
last_modified='' # Last modified file in code directory.
file_path='' # Full file path of last modified file.


# Gets the last modified file in the code directory.
get_filename(){
    cd "$code_directory"
     last_modified=$(ls -t | head -n1)
    echo "$last_modified"
}


# Returns full file path.
get_full_path(){
    # $1=filename
    export file_path="$code_directory$1"
    echo "$file_path"
}


# Stops script if last modified file is this one.
check_filename(){
    # $1=file path
    # Guard clause to prevent recursive call.
    if [ "$1" == 'run_last_modified.sh' ]; then
        msg='Last modified file is run_last_modified.sh.
            Stopping execution...'
        notify-send "$msg";echo "$msg"
        exit
    fi
    echo "$1"
}

# Makes file executable if it isn't already.
make_executable(){
    #$1=file_path
    msg="Making $file_path executable..."
    echo "$msg"
    sudo chmod +x "$1"
    echo "$1"
}

# Opens a new terminal window and runs the file.
run_in_terminal(){
    #$1=file_path
    msg="Running $1 in $qube_name Terminal..."
    notify-send "$msg";echo "$msg"

    # -x option deprecated.  

    sudo gnome-terminal -x --window --wait --tab --active --title="$1" --geometry=120X60 \
    --working-directory="$code_directory"  --command "$file_path"

    # For dom0
    # qvm-run "$qube_name gnome-terminal -e $file_path"
}

run(){
    # Pipeline
    last_modified=$(get_filename)
    file_path=$(get_full_path)
    check_filename "$file_path"
    make_executable "$file_path" 
    run_in_terminal "$file_path"
}

run

################## TESTS #################
# Note to self: Comment out run ^^^ before running tests.

tests(){
    # get filename test.
    last_modified=$(get_filename)
    msg="Last modified: $last_modified"
    notify-send "$msg";echo "$msg"

    # get filepath test.
    file_path=$(get_full_path "$last_modified")
    msg="File path: $file_path"
    notify-send "$msg";echo "$msg"

    # Check filename test.
    # last_modified='run_last_modified.sh'
    # check_filename # Should stop execution.

    # Make executable tests.
    make_executable "$file_path"

}

# tests

-x and --command are incorrect/obsolete options, try this :

sudo gnome-terminal --window --wait --tab --active --geometry=120X60 \
    --title="$1" --working-directory="$code_directory" -- "$file_path"

To keep the terminal window open :

sudo gnome-terminal --window --wait --tab --active --geometry=120X60 \
    --title="$1" --working-directory="$code_directory"\
    -- bash -c "$file_path; exec bash"