在zsh中的参数串联排除了某些字母

huangapple go评论92阅读模式
英文:

Argument concatenation in zsh excludes certain letters

问题

我正在Arch Linux上使用zsh。我已启用setopt extendedglobsetopt sh_word_split。我有以下脚本:

  1. #!/bin/sh
  2. old_IFS="$IFS"
  3. IFS='|'
  4. files_to_exclude="$*"
  5. IFS=old_IFS
  6. cmd="rm -f -- ./^("
  7. cmd+="$files_to_exclude"
  8. cmd+=")"
  9. echo $cmd

当传递给此脚本的参数包含以下任何字符:dloFIS时,它们不会打印到控制台上。为什么会这样,如何强制zsh将它们打印出来?

这是我进行的测试:

  1. ./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
  2. 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:

  1. #!/bin/sh
  2. old_IFS="$IFS"
  3. IFS='|'
  4. files_to_exclude="$*"
  5. IFS=old_IFS
  6. cmd="rm -f -- ./^("
  7. cmd+=$files_to_exclude
  8. cmd+=")"
  9. 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:

  1. ./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
  2. 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

  1. - IFS=old_IFS
  2. + IFS=$old_IFS

huangapple
  • 本文由 发表于 2023年6月25日 20:24:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550372.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定