fedarovich / qbittorrent-cli

Command line interface for QBittorrent
MIT License
312 stars 17 forks source link

Filename is incorrectly interpreted as glob pattern #97

Closed nielsadb closed 8 months ago

nielsadb commented 9 months ago

qbt does not accept filenames containing square brackets, either using wildcard/glob or via a direct properly escaped name. See the code block below for details. It does work by adding quotes and escaping the square brackets manually. This is not what Unix shells like zsh do out of the box. I find it difficult to track down what's happening since the version I have installed (via Homebrew) seems slightly outdated compared to the sources on Github, but my guess is that qbt interprets the name as a glob pattern. A way to tell it explicitly it's a file, as described in the (outdated) documentation, might be helpful. (Note that on Unix, including MacOS, the shell typically does the expansion of glob-patterns, e.g. echo *.torrent executed in my test directory yields output [test].torrent. This behavior is different on Windows, and maybe different between PowerShell and the old cmd)

~ qbt app version
qBittorrent version info:
App version: v4.5.2
API version: 2.8.19
~ qbt version
qbt - qbitttorrent cli
Version: 2.0.0
Commit: Homebrew
Date: 2023-09-24T16:36:39Z
~ ls -l *.torrent
-rw-r--r--@ 1 niels  staff  37286 Jan  4 22:04 [test].torrent
~ qbt torrent add *.torrent
found 0 torrents matching [test].torrent
~ qbt torrent add \[test\].torrent
found 0 torrents matching [test].torrent
~ qbt torrent add [test].torrent
zsh: no matches found: [test].torrent
~ qbt torrent add "[test].torrent"
found 0 torrents matching [test].torrent
~ qbt torrent add "\[test\].torrent"
found (1) torrent(s) to add
successfully added torrent: 262431cce8a136d716ee6791e6c0e5583b245c8a
successfully added 1 torrent(s)
~ uname -a
Darwin Nielss-MacBook-Air.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:34 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8103 arm64
~ echo $SHELL
/bin/zsh
fedarovich commented 8 months ago

Glob expansion is done by the shell, and it's an expected behavior. In order to avoid it, you can either enclose string in single quotes ('[test].torrent'), or escape special symbols with backslash, as you do.

However, looking into the qbt version and the commands you posted, it seems that you are using some different tool, not the one in this repository.