zopencommunity / perlport

Perl programming language
Apache License 2.0
6 stars 3 forks source link

perl -pie doesn't preserve tagging or contents' codepage #64

Closed covener closed 6 months ago

covener commented 1 year ago

I found that the common perl -p -i -e has a confusing side effect of changing the files codepage. If the file will be read back in an env w/o conversion, it could cause an issue.

The Rocket port of perl, at least the old one on my system, doesn't change it.

#!/bin/sh

which perl

export _BPXK_AUTOCVT=ON
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"

rm -f ebcdic-file
touch ebcdic-file
chtag -tc ibm1047 ebcdic-file
printf 12345 >> ebcdic-file
ls -T ebcdic-file
/bin/od -t x1 ebcdic-file

perl -p -i -e 's/12345/1111/' ebcdic-file
ls -T ebcdic-file
/bin/od -t x1 ebcdic-file
$ ./test.sh
/u/WASTST1/zopen/prod/perl/bin/perl
t IBM-1047    T=on  ebcdic-file
0000000000    F1  F2  F3  F4  F5
0000000005
t ISO8859-1   T=on  ebcdic-file
0000000000    31  31  31  31
0000000004

(sed port has the same problem)

covener commented 1 year ago

https://github.com/ZOSOpenTools/sedport/issues/7

covener commented 6 months ago

@IgorTodorovskiIBM any chance the recent work on gzip helps/applies to perl and sed with -i? (bump)

IgorTodorovskiIBM commented 6 months ago

Nope, but thanks for bumping this, we'll look into it.