Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: special characters in file names issue



On 11/10/23, Jim <linux.tech.guy@xxxxxxxxx> wrote:
> Hi everyone,
>
> Using scripts, looking to cleanup duplicate files even if named
> differently.
> The issue I ran into is when a file path contains parentheses. '(' or ')'
>
> Example File Name:  Wallpapers/Web_downloads/05 (1).jpg
>
> The following is part of an anonymous function:
>
> local E
> local -a AllFileNames
> local -A FileNameCkSum
> ...
> for E (${(@)AllFileNames}) {
> [[ -v FileNameCkSum[$E] ]] || FileNameCkSum[$E]=${$(shasum -a 1 $E)[1]} }
> # line that fails
> ...
>
> AllFileName contains the result of a glob statement.
>
> Error Message:  (anon):<line no>: invalid subscript
>
> I'm sure this is a quoting issue, but everything I've tried so far has
> failed.
>
> If someone could point me to documentation or examples it would be
> appreciated.

The code you posted works fine (although it would be appreciated if
you posted actually runnable minimal test cases, rather than
excerpts).

PS gmail flagged your mail as spam, possibly because your From: and
Reply-to: headers contain different addresses.

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author