From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24306 invoked from network); 10 Nov 2023 14:18:41 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Nov 2023 14:18:41 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1699625921; b=VysrWu4W2ZYM6XG3aE72DmjQLASN9zCmKAxPTn6JyEsnLge34Pg1EgAR8lGPFYLiGAh+PPW5Bh UnlgOYR+gzvdkoH9z/qOpfqM5kLrYNWWkpW8ApE69u7r4pJNXsQDrwjSrl5d/DPaK/oJ7quepw IYv5NuPKrSdCF7KDgAbKAc0ZvAEObuWffEXK0NPRBhiIDnJyuKPsM+vC1F0XtgDmaHW5ixzWVC UTBNy2S6InLCkS27q3zZuc52ceO3hhgq8KeblN0HZO43XSjbAcZ4Kl8FSJ5VEON/tvW1IYmj2c to8QU9dh54zkIZnK6GKS0cVuxcvd5FkcUVgFrR5/4IAN2g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1699625921; bh=CmRgnY2ptUI81bN4wK+E6nmjoA8GO/X5TNQhQvugML0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=DofRonZ1gYS53lo+aifCvaRXg16WgsDdOnNlduhTviWl+KuD4iXyYYuGjL8bA0e+IOnqgMtDtT xcdLTP3ejmUIS9hwCN9YSkx8S6T0JIJ85vYwr1B7sKSO0L2USt66Y4jLesEfb500XExl5KPt7W QGrUqEcoQ/gbg3FJ+S+aQJr7/0f0PuNRsExQfLTxoM7X20NaUV01IQzSHkVyITNiF6zlYF47bm hoiisiS2PzQmS7/3tUmuX7J7jut4NPJcQvt8/C0z7iGgc8JVf/dT6EApxGKu2I2TIFvsC8hJAP tgowy8uHrkHrGnEwjf3n9JmvSDLH8Cq6ygGYFevIfiYwzA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=XhRLzNSGuGmhBtJqRlgut/nZAd0Y534PYHB4pASASRU=; b=Y5HL+uvxcS9CsRnpHWO1orCErc 36GXb45F3YvfkQ7ClpDEXbz7ooeAhzgiAsitlRP+9/nNGMu/Xt3beoJuqSXthT1uTDR/EAj9+Je1L YCmqlm9obFT9genPA7at2yMVonG+v6Olt1jv0dEjvtiHOPq1JrWg1olTTwkw8cgCCu/jaMNcItppg qtrUHPm09aj6uq3p2P2mAcVUF1LFNBrQwkV9xrK2UsbEb3tVmRi2t3ysNbe3+P31+h/5m1SXsAX16 +TQc5Ce4PcYu7nS8zFfrEfsPuISGmD/BpkHoiwn3okGnMlge457McUxIDUQB3m6q93yKhuhSJuAoq v09Kchwg==; Received: by zero.zsh.org with local id 1r1SLI-000A7P-Mf; Fri, 10 Nov 2023 14:18:40 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f42.google.com) smtp.remote-ip=209.85.208.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f42.google.com ([209.85.208.42]:52411) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1r1SKL-0009PU-Dg; Fri, 10 Nov 2023 14:17:42 +0000 Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-53ed4688b9fso3359079a12.0 for ; Fri, 10 Nov 2023 06:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699625861; x=1700230661; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XhRLzNSGuGmhBtJqRlgut/nZAd0Y534PYHB4pASASRU=; b=PKQYwD9ZkIW02Qah4/wMqDumcxU2nu0LCRfeDTU7dB4TOiAomw7ELsJkvLQUSJWYsI E9k430+ObftVYxv2Y0o8U9lBtIhBQYthTn21fy1DXJKC9wI5rXuXvcv/x1B+UJ1vGt0J KwNfqk2g9ZkUKCallOa3yTtbCNjjKMCSWH8KMHHxw2MGCnJC5JTYtPxD15DTsPdNPQ5U 3yGnnSSXkBZmreuIgJ+5xW0aY1XIDEom7ZPqHmrivMRWPR4MTtyNKm1810PVnar1qQ5h 9P1xMPhPILv0YMMyU3I42WCT1W8YxSPnl0G+eMy4mnguD6MlJMFmfHptxT7ECAWG6PGW 2BYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699625861; x=1700230661; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XhRLzNSGuGmhBtJqRlgut/nZAd0Y534PYHB4pASASRU=; b=lMknVt4lGcunIowRYdYBK6Dqm+UFdBmSmHmp+Q09bmYgv+DrmKDszrOl/XIYTEfFJ0 GBb+rz2+8jKg3WCYZBvAhA6iijUbty0cQnFthKNnxLDsHmtar9S1NqXaASzKfyvhl9z2 xUvyRjiQixnHtYXi7rMOFpw/8hI51Q7or+KoCq34SNDUc81W0tjkUPTDe3EVva+zfwK5 1yh9a8kap+jPotdpviM/MG8HnI375lH5M1dRhft0ZXj16QUP8N4Rqx3FPn5utx+zzFdC ENNuVwUyUgDDrPQqK5jWIWa23EPuoIrDg17keWCq4Ucrf/Mk4Drjaucha+3dnT3qRaz4 GxkQ== X-Gm-Message-State: AOJu0YwCz3zC8WaOBX2rGrZRD0YicmngkTpJ55Q+NjSjtNBsM35E3skl QxT6w52wnEo7LrE/8MEiJ2+EUtbk1QWmwTGB7WxzamsC X-Google-Smtp-Source: AGHT+IEXVPd6yYi4r+R9WdZGinH32sGKCEzCpCcmX5vKGgUTtuyWoaloGD0i7vLC1/m0FvUiaVN8IBbMfzJ+4cmU8J0= X-Received: by 2002:a50:cd95:0:b0:53f:bd95:d963 with SMTP id p21-20020a50cd95000000b0053fbd95d963mr6456220edi.32.1699625860790; Fri, 10 Nov 2023 06:17:40 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:7208:3187:b0:77:b33a:7b21 with HTTP; Fri, 10 Nov 2023 06:17:40 -0800 (PST) In-Reply-To: References: From: Mikael Magnusson Date: Fri, 10 Nov 2023 15:17:40 +0100 Message-ID: Subject: Re: special characters in file names issue To: Roman Perepelitsa Cc: linuxtechguy@gmail.com, zsh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29337 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 11/10/23, Roman Perepelitsa wrote: > On Fri, Nov 10, 2023 at 12:17=E2=80=AFAM Jim w= rote: >> >> 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]=3D${$(shasum -a 1 $E)[1]= } } >> # line that fails >> ... >> >> AllFileName contains the result of a glob statement. >> >> Error Message: (anon):: invalid subscript > > Associative arrays in zsh are finicky when it comes to the content of > their keys. The problem you are experiencing can be distilled to this: > > % typeset -A dict > % key=3D'(' > % [[ -v dict[$key] ]] > zsh: invalid subscript > > There is no simple quoting that you can apply to $key here: (q), (b), > etc. are all wrong. You could perhaps escape a specific list of > characters ('(', '[', '{' but not '$' or '*') although my memory tells > me that some keys cannot be made to work under `[[ -v ...]]` or > `unset` no matter how you try to escape them. I could be wrong though. Not sure why I didn't get this error when testing yesterday, but in this case you can also avoid it by using the more typical (( $+dict[$key] )) test instead of [[ -v ...]]. --=20 Mikael Magnusson