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

Fix unexpected behavior for bash/ash #56

Merged
merged 1 commit into from
Jul 4, 2021
Merged

Conversation

zzjjbb
Copy link
Contributor

@zzjjbb zzjjbb commented May 22, 2021

When a folder name contains [ ], the ${a#$b} will not work as expected (tested on bash/ash/zsh, and the first 2 cannot work. However, zsh can work)

Example

bash/ash

a="/[1]/2.txt"
b="/[1]/"
echo "${a#$b}"
echo "${a#"$b"}"
# output:
# /[1]/2.txt
# 2.txt

zsh

a="/[1]/2.txt"
b="/[1]/"
echo "${a#$b}"
echo "${a#"$b"}"
# output:
# 2.txt
# 2.txt

之所以发现这个隐蔽的问题,是因为:

我用那个aria2pro docker下载多个大文件到同一个文件夹,文件夹名字大概是这样的[210522] Folder Name,结果rclone的时候网速跑的飞快,CPU也占满,但是很久才能完成,有时还有hash check error的错误,查看统计信息container的输出流量竟然是输入流量的数倍。最后发现是rclone是对整个目录进行move的,多个文件就同时move了多次,各种冲突。而且测试的时候怎么都没问题,正式下载就出错。查了半天才发现是这个中括号的问题:rage: 之前没有怎么用过Linux shell,一开始啥也看不懂。。。

When a and b contains `[ ]`, the ${a#$b} will not work (tested on bash/ash/zsh, and the first 2 cannot work. However, zsh can work)
@vercel
Copy link

vercel bot commented May 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/p3terx/aria2-conf/7KeLVgmBWcQEiK5zAFVZh8mLmZvu
✅ Preview: https://aria2-conf-git-fork-zzjjbb-patch-1-p3terx.vercel.app

@P3TERX
Copy link
Owner

P3TERX commented Jul 4, 2021

感谢!

P3TERX pushed a commit that referenced this pull request Jul 4, 2021
P3TERX pushed a commit that referenced this pull request Jul 4, 2021
asfork added a commit to asfork/aria2.conf that referenced this pull request May 21, 2022
commit 9286d0b
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Wed Sep 15 13:30:50 2021 +0800

    Modify User Agent parameters

commit aad12fa
Author: fengguowudi <55879152+fengguowudi@users.noreply.github.com>
Date:   Wed Sep 15 13:24:55 2021 +0800

    Modify client camouflage parameters (P3TERX#58)

commit 97b1758
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Tue Sep 14 14:42:04 2021 +0800

    Version number revision

commit 96cabfb
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Tue Sep 14 14:08:54 2021 +0800

    Update DHT file

commit 16be7b8
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Tue Sep 14 14:07:30 2021 +0800

    core: Fix grammatical errors

commit 1d334e3
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Sun Jul 4 19:10:31 2021 +0800

    Update README.md

commit 8af2e31
Author: zzjjbb <31069326+zzjjbb@users.noreply.github.com>
Date:   Sun Jul 4 03:24:25 2021 -0400

    Fix unexpected behavior for bash/ash (P3TERX#56)

commit 8989aa5
Author: Derek Zhu <1and1get2@gmail.com>
Date:   Thu Apr 22 00:16:12 2021 +1200

    support "CUSTOM_TRACKER_URL" as a single url or a list of urls (P3TERX#54)

commit 1c5a197
Author: Derek Zhu <derek.zhu@genesisenergy.co.nz>
Date:   Wed Apr 14 23:56:13 2021 +1200

    added support for exclude-file-regex & include-file-regex (P3TERX#54)

commit 7994500
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Tue Dec 29 00:49:15 2020 +0800

    aria2.conf: add option 'http-want-digest'

commit 31e5ecb
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Thu Dec 24 23:51:57 2020 +0800

    Update README.md

commit 213ce6b
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Thu Dec 24 14:52:43 2020 +0800

    aria2.conf: Disk IOPS Optimization and Other Additional Notes

commit 9a20d2e
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Tue Dec 15 10:44:30 2020 +0800

    aria2.conf: Stability optimization and additional notes

commit 6799a7f
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Wed Dec 9 06:35:23 2020 +0800

    Update README.md

commit 40fb1ef
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Wed Dec 9 06:21:21 2020 +0800

    Update DHT file

commit 4e8d762
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Wed Dec 9 06:20:18 2020 +0800

    aria2.conf: Add some advanced options

commit b40f9bc
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Wed Dec 9 01:50:32 2020 +0800

    aria2.conf: Update User Agent

commit abb8f8e
Author: P3TERX <25927179+P3TERX@users.noreply.github.com>
Date:   Thu Nov 26 16:47:11 2020 +0800

    Improve RCLONE environment variable file loading method

commit 114c5c0
Author: P3TERX <p3terx@outlook.com>
Date:   Sat Aug 29 01:54:51 2020 +0800

    Update DHT file

commit dba7be2
Author: P3TERX <p3terx@outlook.com>
Date:   Sun Aug 9 08:19:24 2020 +0800

    tracker.sh: Update URLs

commit c9c0fd3
Author: P3TERX <p3terx@outlook.com>
Date:   Sat Aug 8 09:59:39 2020 +0800

    additional comment

commit bf6ba07
Author: P3TERX <p3terx@outlook.com>
Date:   Sat Aug 8 09:41:29 2020 +0800

    Add option: pause-metadata
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