9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Can you plumb a file with a single quote in the filename?
@ 2025-01-26 21:19 fosskapper
  2025-01-26 23:10 ` Steve Simon
  0 siblings, 1 reply; 3+ messages in thread
From: fosskapper @ 2025-01-26 21:19 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]

I am currently using Acme (the Plan9ports version) on my Raspberry Pi 4B using Raspberry Pi OS. It works very well and I enjoy using it, but recently I have encountered a problem that I can't seem to solve.

I need to work with PNG image files that have been created and named by other people. When I create a file, I am very conservative about which characters I use in the filename (alphanumeric, underscore, and sometimes hyphen). These PNG image files, however, frequently contain parentheses, pound signs, and single quotes (apostrophes), like these:

Mary's first attempt (edited) #confirmed.png
John's second attempt (original) #unconfirmed.png

I have been able to create a plumbing rule that handles all of the characters in the filenames above, except for the single quotes (apostrophes). Whenever I try to include an escaped single quote in the "data matches" string, the plumber gives me this error when I use the "cat $HOME/lib/plumbing | 9p write plumb/rules" command to refresh:

9p: write error: runaway quoted string literal

This is the plumbing rule that is giving me the problem:

 # image files go to eom
type is text
data matches '[a-zA-Z¡-�0-9_\-./@ \(\)\']+'
data matches '([a-zA-Z¡-�0-9_\-./@ \(\)\']+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG|webp|WEBP)'
arg isfile      $0
plumb to image
plumb start eom $file

I don't know much about the plumber, so I am probably doing a lot of things wrong, but I would be very grateful for any help that anyone could provide. Thank you.

And by the way -- I know that in a filename with spaces, you need to swipe the entire filename first before you right click in order to have the click "take".

Thanks again.

--
Foss

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T3cd2a871851787df-Mad2171908e7e8ccd61b0abf4
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 2976 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Can you plumb a file with a single quote in the filename?
  2025-01-26 21:19 [9fans] Can you plumb a file with a single quote in the filename? fosskapper
@ 2025-01-26 23:10 ` Steve Simon
  2025-01-27  0:24   ` fosskapper
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Simon @ 2025-01-26 23:10 UTC (permalink / raw)
  To: 9fans

i haven’t tried this but i suspect you can put a single quote in by doubling it.

e.g. 
  data_matches ‘[abc’’]def’
which should match any of
  adef
  bdef
  cdef
  ‘def

one of the many wonderful things about plan9 is its uniform escaping and regex rules

-Steve



------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T3cd2a871851787df-M16811a55716fe27dc3fe7c4a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Can you plumb a file with a single quote in the filename?
  2025-01-26 23:10 ` Steve Simon
@ 2025-01-27  0:24   ` fosskapper
  0 siblings, 0 replies; 3+ messages in thread
From: fosskapper @ 2025-01-27  0:24 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

Thank you! Doubling the single quote did the trick. I appreciate the help.

--
Foss

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T3cd2a871851787df-M34792420aa0b159ac1b24408
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 870 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-27  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-26 21:19 [9fans] Can you plumb a file with a single quote in the filename? fosskapper
2025-01-26 23:10 ` Steve Simon
2025-01-27  0:24   ` fosskapper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).