1

The following doesn't work for me:

#!/bin/bash

commands () {
    cd ~/Yola
    pwd
}

export -f commands

konsole --noclose -e "bash -c 'commands'" 

New konsole opens, but commands are not executed.

1 Answer 1

1

Double quotes around a string parsed as an argument mean that string is run as a child process, i.e. it's contents do not affect the parent process.

Single quotes don't do anything to the characters between them, so switch double quotes for single quotes on your last line, like so:

konsole --noclose -e 'bash -c commands'

(Your commands function doesn't need any quotes around it.) If you are running a long list of commands in this way, I recommend the -x flag which prints out commands and output in order. Use konsole --noclose -e 'bash -cx commands' to get the following print out:

+ commands + cd ~/Yola + pwd /home/Yola

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .