英文:
Argument concatenation in zsh excludes certain letters
问题
我正在Arch Linux上使用zsh。我已启用setopt extendedglob和setopt sh_word_split。我有以下脚本:
#!/bin/sh
old_IFS="$IFS"
IFS='|'
files_to_exclude="$*"
IFS=old_IFS
cmd="rm -f -- ./^("
cmd+="$files_to_exclude"
cmd+=")"
echo $cmd
当传递给此脚本的参数包含以下任何字符:d、l、o、F、I或S时,它们不会打印到控制台上。为什么会这样,如何强制zsh将它们打印出来?
这是我进行的测试:
./script_name a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I
J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0
英文:
I'm using zsh on Arch Linux. I have enabled setopt extendedglob & setopt sh_word_split. I have the following script:
#!/bin/sh
old_IFS="$IFS"
IFS='|'
files_to_exclude="$*"
IFS=old_IFS
cmd="rm -f -- ./^("
cmd+=$files_to_exclude
cmd+=")"
echo $cmd
When the arguments given to this script contain any of: d, l, o, F, I or S, they are not printed to the console. Why is that and how can I force zsh to print them?
Here's what I tested against:
./script_name a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I
J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0
答案1
得分: 2
有一个拼写错误
- IFS=old_IFS
- IFS=$old_IFS
英文:
there's a typo
- IFS=old_IFS
+ IFS=$old_IFS
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论