[Bug] Shell commands execution bug

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
veatroub
Junior Member
Junior Member
Posts: 19
Joined: 2014-05-08, 12:21 UTC

[Bug] Shell commands execution bug

Post 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?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The shell seems to interpret some characters like '(' differently even when you put them in double quotes. :(
Author of Total Commander
https://www.ghisler.com
User avatar
veatroub
Junior Member
Junior Member
Posts: 19
Joined: 2014-05-08, 12:21 UTC

Post 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!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Where do you try to do this? Have you tried to change the parameters of the button yourself?
Author of Total Commander
https://www.ghisler.com
User avatar
veatroub
Junior Member
Junior Member
Posts: 19
Joined: 2014-05-08, 12:21 UTC

Post 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.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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.
Author of Total Commander
https://www.ghisler.com
User avatar
veatroub
Junior Member
Junior Member
Posts: 19
Joined: 2014-05-08, 12:21 UTC

Post 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.
Post Reply