Passing a bracket to a shell

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
igoryan94
Posts: 45
Joined: 29 Jan 2016 18:10

Passing a bracket to a shell

Post by igoryan94 » 18 Apr 2017 20:37

How can I pass brackets ('{' and '}') with a shell command to get normal result? They are immediately expanded by Automatic as script code, but I need to pass them to shell as normal bracket symbols..
Command is: "set -- `cat /proc/meminfo`; echo $(($5+${11}))".
It must normally get free RAM (as I said, it does not work in Automagic because ${11} must expand into 11-th field (a shell variable), not in constant 11). This is not unique situation, there are too many shell-commands that do not work because of that behavior.
Can someone tell me how can I fix this problem with shell scripts?
P.S.: Help contains nothing about that problem.
P.P.S.: It even will not work if I will compile the command into a variable with script action like this: "cmd = "set -- `cat /proc/meminfo`; echo $(($5+$\{11\}))"". Is this all a bug or can I make this all to execute correctly?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Passing a bracket to a shell

Post by Martin » 19 Apr 2017 19:12

Hi,

Variables in curly braces are replaced before the command is executed.
A similar topic was discussed here:
http://automagic4android.com/forum/view ... 364#p17337

Regards,
Martin

igoryan94
Posts: 45
Joined: 29 Jan 2016 18:10

Re: Passing a bracket to a shell

Post by igoryan94 » 20 Apr 2017 11:12

Thanks!

Post Reply