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

Force locale settings into POSIX #207

Merged
merged 1 commit into from
Aug 16, 2021
Merged

Force locale settings into POSIX #207

merged 1 commit into from
Aug 16, 2021

Conversation

wh201906
Copy link
Contributor

@wh201906 wh201906 commented Aug 14, 2021

Hi there.
The script doesn't support systems with non-English locale settings now.
In CJK (Chinese, Japanese and Korean) computing,
graphic characters are traditionally classed into fullwidth.
For users who use CJK locales, the colon in the output is ':', rather than ':'.
The script cannot handle these characers, so forcing locale settings into English temporarily can solve this problem.

In CJK (Chinese, Japanese and Korean) computing,
graphic characters are traditionally classed into fullwidth.
For users who use CJK locales, the colon in the output is ':', rather than ':'.
The script cannot handle these characers, so forcing locale settings into English temporarily can solve this problem.
@wh201906
Copy link
Contributor Author

wh201906 commented Aug 14, 2021

For example, on Ubuntu 20.04.2 LTS with locales setting to zh_CN
If i run the script in the "master" branch, the output is:

pishrink.sh v0.1.2
pishrink.sh: Gathering data ...
pishrink.sh: Checking filesystem ...
rootfs:118051/242880 文件(0.7% 为非连续的), 916585/983040 块
resize2fs 1.45.5 (07-Jan-2020)
./pishrink.sh: 行 326: [[: 预计文件系统的最小尺寸:948913:语法错误: 需要操作数 (错误符号是 "预计文件系统的最小尺寸:948913")
./pishrink.sh: 行 332: 983040 - 预计文件系统的最小尺寸:948913:语法错误: 需要操作数 (错误符号是 "预计文件系统的最小尺寸:948913")
pishrink.sh: Shrinking filesystem ...
resize2fs 1.45.5 (07-Jan-2020)
resize2fs: 无效的新大小: 预计文件系统的最小尺寸:948913

pishrink.sh: ERROR occurred in line 347: resize2fs failed with rc 1

The script failed to continue because the output of resize2fs contains non-ASCII characters.
Also, " cut -d ':' " cannot handle fillwidth colon ':'

If I run the script in the "wh201906_locale" branch, the output is:

pishrink.sh v0.1.2
pishrink.sh: Gathering data ...
pishrink.sh: Checking filesystem ...
rootfs: 118051/242880 files (0.7% non-contiguous), 916585/983040 blocks
resize2fs 1.45.5 (07-Jan-2020)
pishrink.sh: Shrinking filesystem ...
resize2fs 1.45.5 (07-Jan-2020)
Resizing the filesystem on /dev/loop14 to 953913 (4k) blocks.
Begin pass 2 (max = 17191)
Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 30)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop14 is now 953913 (4k) blocks long.

pishrink.sh: Shrinking image ...
pishrink.sh: Shrunk 1.img from 4.1G to 3.9G ...

Everything works fine. The locale settings only affect the script and its sub processes

@Drewsif Drewsif merged commit 43f1a88 into Drewsif:master Aug 16, 2021
@wh201906
Copy link
Contributor Author

Thanks

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

Successfully merging this pull request may close these issues.

2 participants