Odd behavior when running kate in bash script

running kate from a bash script may (or not) result in odd bash errors - for ex…

kate -- 'file1' 'file2' &> '/dev/null' & disown

… may result in a random error such as: isown: command not found

which is interesting because ‘isown’ is ‘disown’ without the ‘d’

anybody know what’s going on?

according to the fellas over at KDE, it’s not a kate issue

I would say just correct your syntax, valid options are listed here:

https://docs.kde.org/stable5/en/kate/kate/fundamentals.html#starting-from-the-command-line

1 Like

Try kate -- 'file1' 'file2' &> '/dev/null' &; disown

i will give that a shot and let you know if it werx :slight_smile:

shellcheck screams at me if i do that and i depend on it to keep me sane

isn’t that the same as putting disown on the next line anyway?

Remove the -- .

Though … it works for me with it there. Im also using Konsole and Bash if that matters.

$ kate ./file1.txt file2.txt > /dev/null & disown
[1] 28157
$ kate ./file1.txt file2.txt &> /dev/null & disown
[1] 28198
$ kate -- ./file1.txt file2.txt &> /dev/null & disown
[1] 28764

Also worked in a script.

#!/usr/bin/env bash
kate -- ./file1.txt file2.txt &> /dev/null & disown

I wonder what your script looks like?

According to Cristoph Cullmann on that bug report:

hi @cscs - it works for me too… sometimes… and sometimes not - i get the errors probably 2 of 5 runs or so regardless of whether the -- is there

here’s an excerpt from the script…

a=(
    ''
    'WARNING: There were issues with this file.'
    'Open the relevant files for viewing? [Y/n]'
)
printf '%s\n' "${a[@]}"
read -rsN1
if [[ "${REPLY}" != 'n' ]] ; then
    # running kate with '&> '/dev/null' & disown' sometimes results in random erroneous errors such as...
    # ./wpc.sh: line N: isown: command not found
    # see: https://invent.kde.org/utilities/kate/-/issues/113#note_780703
    kate -- 'errors.txt' "${sFile}" &> '/dev/null' & disown
    #stty 'sane'
    printf '%s\n' 'Press any key to continue...'
    read -rsN1
fi

the error “isown: command not found” is random - that only happened once - other times the ‘not found’ commands are random characters from the script, all of which are located after the kate command i believe so i’m not sure you’d see the errors in a 1 line script

if you decide to test further, be careful because bash tries to exec the characters

Well bash apparently disagrees in some edge cases. Perhaps it’s a bug. I’ve heard that zsh handles this better but I use bash myself.

Yes.

I tend to agree with the comment in the link provided - the issue is likely found in your script - most probably a variable having unexpected content.

When a program - in this case a script - mishaves when provided with arguments - then validate the input.

Of course you have likely thought of it - so just for the record - add a line printing the command before the actual execution will provide hints as to what is eating the d

echo kate -- 'errors.txt' "${sFile}" &> '/dev/null' & disown