Quoting brackets inside a bash function
Hey!
I want to use in console a fine calculator Qalculate! It can manage ISU units, brackets - its something like science calculator. I can use it like this: Code:
$ qalc 2+2 Code:
$ qalc (2+2)2 I can quote it in several ways and then it's work fine: Code:
$ qalc "(2+2)2" Code:
$ c (2+2)2 Code:
function c() { qalc $@; } Sorry for my English. |
I don't know the software qalc, but in console, you should be able to do simple arithmetics by default:
Code:
ted:$ echo $((2+2)) Ted |
To multiply, you need "*"----eg:
(2+2)*2 |
Yes, I'm know that. I use tilda console, and I want to be able to do some quick calculations without problems.
Code:
$ qalc "(54km-456m)/(5h+55s)" Code:
$ c (54km-456m)/(5h+55s) |
Quote:
Code:
$ qalc "(2+2)2" |
can you post the outputs of
Code:
ls /bin | grep qalc I am trying to get the env here. Ted |
Code:
$ ls /bin | grep qalc |
do
Code:
ln -s /usr/bin/qalc /usr/bin/c Code:
c "(2+2)2" |
But it works just fine. I can do
Code:
c "(2+2)2" Code:
c (2+2)2 |
Can you do
Code:
c \(2+2\)2 To my knowledge, () are special characters in bash, without quotation marks, you DO need to escape them, because bash will parse them specially. |
yes, I can. I thought it can be done to somehow pass over this rule, and simplify the command.
Thanks for your help. |
Just to make it clear, this simply cannot be done without quoting.
Since the shell parses the line before executing it, and since parentheses and several other characters have special meanings to it, they must be protected from the shell in order for them to be properly passed to the command. This is true of all commands, BTW. If a raw text string contains anything the shell could consider special, those characters have to be escaped first, either with quotes or backslashes. You can, however, always execute qalc in interactive mode, where you can talk to it directly without the shell getting in the way. |
All times are GMT -5. The time now is 07:49 AM. |