Page 1 of 1

[Bug] Shell commands execution bug

Posted: 2014-05-08, 15:03 UTC
by veatroub
Hello.
I've noticed that shell command execution with "%P%N" argument causes a bugs:

Code: Select all

sh: <stdin>[1]: cd: too many arguments
if file name contains some spaces and

Code: Select all

sh: <stdin>[1]: syntax error: '(' unexpected
if file name contains braces (and may be some other symbols that must be escaped in shell).
I can see an execution of "cd %P" command right before execution of my command (my command has quoted "%P%N") in SuperSU logs. Path in this "cd" is not in quotes and is not escaped with backslashes.
This is the reason of failure. Can you fix this?

Posted: 2014-05-09, 14:19 UTC
by ghisler(Author)
The shell seems to interpret some characters like '(' differently even when you put them in double quotes. :(

Posted: 2015-02-01, 11:55 UTC
by veatroub
Hello again.
I'm using 2.50 final for now, but I still have old problems and one new.

ghisler, please, just wrap path with double quotes in command cd %P, which Total Commander executes before user shell command.
For example, I'm trying to execute following command in directory "/sdcard/My Dir"

Code: Select all

ls -al "%P"
In SuperSU logs I see

Code: Select all

cd /sdcard/My Dir
ls -al "/sdcard/My Dir"
exit
sh: <stdin>[1]: cd: bad substitution
drwxrwxr-x 3 root sdcard_r 4.0K Nov 29 13:20 Another My Dir/
In first line cd tries to change directory to "/sdcard/My" and not to "/sdcard/My Dir" as it should be and fails, because there is no directory "My" in sdcard. Path should be wrapped with quotes like in second line. In TC's result screen I see only "sh: <stdin>[1]: cd: bad substitution".

And I have another bug. TC shows "[...]" instead of first line of results, if I using "*" as prefix for command (to copy results to clipboard). TC copies text as it should be (first line is normal, not "[...]"). If I delete "*", I would not be able to copy results, but I can see normal first line in popup window. This bug appears every time, when I execute "ls -al" or "cat" commands. In previous stable version I haven't such bug. Please fix it too.

Thanks for a greatest file manager!

Posted: 2015-02-01, 14:03 UTC
by ghisler(Author)
Where do you try to do this? Have you tried to change the parameters of the button yourself?

Posted: 2015-02-01, 18:23 UTC
by veatroub
I just created a button with "Send shell command", "su" and "*ls -al "%P"" parameters.
If I press it when in directory, which name contains spaces, I see a "bad substitution" error.
If I press this button when opened directory, which name has no spaces, TC loses first line of results in popup window titled "su" with "Copy to clipboard" button. TC shows "[...]" instead of first line of results.
If I delete "*" in this command, TC displays a toast with all results and there is no "[...]" string like in previous case. It just displays all lines returned from "ls" as it should be.

Posted: 2015-02-02, 14:07 UTC
by ghisler(Author)
Ah, I think I understand now: TC calls
cd directory
before executing a command. It seems that I need to put that into double quotes. It's not a problem with the actual command. Thanks for your help.

Posted: 2015-02-02, 17:40 UTC
by veatroub
Yes, you right, thanks. I will wait for fix. :D
But "[...]" instead of first line appears in 2.50 and not in 2.04, so bug with "cd" and this bug are not the same bug. Fix it too, please. I use buttons with shell commands very often.