utf8-all icon indicating copy to clipboard operation
utf8-all copied to clipboard

Does not work with -s switch

Open appomsk opened this issue 5 years ago • 3 comments

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}'
привет

appomsk avatar Aug 09 '20 12:08 appomsk

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]=привет

HayoBaan avatar Aug 09 '20 13:08 HayoBaan

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.

Leont avatar Aug 09 '20 18:08 Leont

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.

appomsk avatar Aug 11 '20 04:08 appomsk