I found that it happens because it splits entered arguments. But I am creating a program that encrypts string and it encrypted "test" as |m{|
. But when I switch to decryption mode that thing happens. Any solution ?
Asked
Active
Viewed 251 times
2
1 Answers
5
The >
comes from bash
's $PS2
variable. man bash
says:
PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is ``> ''.
I often see >
when I have an unmatched quote ("
) or apostrophe ('
), or some other input that bash
views as incomplete.

waltinator
- 36,399
}
. What's wrong if it is enter within double quotes? I think it is just a filename. Isn't it? – Kulfy Jan 16 '19 at 16:44"|m{|"
'|m{|'
in the shell as an argument to your program, your program will not see the quotes (they will simply prevent the shell from trying to interpret the sequence) – steeldriver Jan 16 '19 at 16:51|
will be treated as pipe symbol and{
as start of compound command, therefore the shell will treat it as part of its syntax and consider the line you entered incomplete. That's what>
signifies. – Sergiy Kolodyazhnyy Jan 16 '19 at 21:07$'\7b'
for{
, but otherwise - no. Quoting is a necessity in this case. If you are OK with usingread
command to prompt user for string, such asread -p "Enter encrypted string:" var_to_store
and then use$var_to_store
- then it can work. Shell won't treat characters specially withread
. But when you type it as./mycommand.sh arg1
, then arg1 has to follow shell rules – Sergiy Kolodyazhnyy Jan 16 '19 at 21:13