Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with -s switch #51

Open
appomsk opened this issue Aug 9, 2020 · 3 comments
Open

Does not work with -s switch #51

appomsk opened this issue Aug 9, 2020 · 3 comments

Comments

@appomsk
Copy link

appomsk commented Aug 9, 2020

Linux Mint 20
Package: libutf8-all-perl
Version: 0.024-1

perl -Mutf8::all -sle 'print $v' -- -v=привет
пÑивеÑ

This does not work either:

perl -CASD -Mutf8 -Mv5.30 -sle 'print $v' -- -v=привет

This works:

perl -MEncode -sle 'print decode("utf-8", $v)' -- -v=привет                                        
привет

By the way:

ruby -se 'puts $v' -- -v=привет 
привет

and

awk -v v=привет 'BEGIN {print v}'
привет
@HayoBaan
Copy link
Collaborator

HayoBaan commented Aug 9, 2020

Interesting, this is the first time I've seen -s in working. I'm not sure I will be able to fix this though; as far as I know I can't access/modify the way -s works 😞

$ perl -CASD -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет 
v=п�иве�
x=п�иве�
ARGV[0]=привет

$ perl -CASD -Mutf8 -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет 
v=п�иве�
x=привет
ARGV[0]=привет

$ perl -CASD -Mutf8::all -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет
v=п�иве�
x=привет
ARGV[0]=привет

$ perl -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет 
v=привет
x=привет
ARGV[0]=привет

$ perl  -Mutf8 -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет     
Wide character in print at -e line 1.
v=п�иве�
x=привет
ARGV[0]=п�иве�

$ perl  -Mutf8::all -sle '$x="привет"; print "v=$v\nx=$x\nARGV[0]=$ARGV[0]\n"' -- -v=привет привет 
v=п�иве�
x=привет
ARGV[0]=привет

@Leont
Copy link
Contributor

Leont commented Aug 9, 2020

I don't think this can be fixed. And quite frankly, people shouldn't be using -s anyway, it's not a particularly good argument parser. Getopt::Long has been the most popular argument parser for more than two decades, and there are several other competent options.

@appomsk
Copy link
Author

appomsk commented Aug 11, 2020

I also thought it was something like a bug in perl. I think it should work with -CA option. Maybe it is necessary to send a bug report, but I don't really use perl very often.

@Leont It's not for perl scripts. This method, like the corresponding option in awk, is used to pass arguments from the shell script to the perl command used in the script. It's just a way to avoid a nightmare with single and double quotes.

I use perl instead of sed and awk because of perl regular expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants