0

I'm doing math parser where I need to have input through command line. So I did it but I have problem that bash is giving me error with -bash: syntax error near unexpected token('` when I input expression like 3*(2). On normal input it's working.

4
  • 1
    Please paste some code Commented Jul 28, 2016 at 18:38
  • oh I solve it.. I need it input like '3*(2)' damn Commented Jul 28, 2016 at 18:39
  • 1
    You should clarify what 'normal input' is (with an example or two). Commented Jul 28, 2016 at 18:44
  • It's math parser so my input was like ./myprog 'sin(25) - 3*(35-1)' etc without these ' ' it wasn't working :) Commented Jul 28, 2016 at 18:46

1 Answer 1

4

Certain characters such as *, (, and ) have special meaning to the shell. You'll need to escape them with a backslash when calling your program:

./myprog 3 \* \( 2 \)
Sign up to request clarification or add additional context in comments.

2 Comments

@JakubStibůrek: backslashes or single quotes both work — and the reason is what dbush stated; they have special meanings to the shell.
Double quotes would probably work too for the kinds of inputs involved, but single quotes are safer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.