how to let script recognize parenthesis input on the command line?
by bsmile from LinuxQuestions.org on (#5H3CA)
I am writing a simple script to let bc evaluate simple math expressions and output on the screen. I write down a file called mybc as
Code:#!/bin/sh
express=$1
echo "scale=6; $express" | bcand run it on the command line as
mybc sqrt(6.0)
and get the following error message
bash: syntax error near unexpected token `('
If I run the following on the command line as
mybc sqrt\(6.0\)
It can work correctly. But I hope mybc can just run as the first way. I searched a bit and landed on the following link
https://stackoverflow.com/questions/...-the-command-l
but it seems to help with parenthesis used within the script, and thus does not help.


Code:#!/bin/sh
express=$1
echo "scale=6; $express" | bcand run it on the command line as
mybc sqrt(6.0)
and get the following error message
bash: syntax error near unexpected token `('
If I run the following on the command line as
mybc sqrt\(6.0\)
It can work correctly. But I hope mybc can just run as the first way. I searched a bit and landed on the following link
https://stackoverflow.com/questions/...-the-command-l
but it seems to help with parenthesis used within the script, and thus does not help.