Somehow I missed that we have a shellescape proc. This is very exciting! I've wanted this function for a long time, and I'm just realizing now that it exists and that we've had it for 6 years.
https://github.com/macports/macports-base/commit/494a1feafa2ad46c66f9714b760fb5b50ff5dd48 Thank you, Clemens! We should be using this everywhere, such as in portextract.tcl. It looks like it is available for use in portfiles too. Portfiles should switch to using this when specifying filenames or paths in a system call instead of manually quoting them with 'quotes' (or, more usually, not doing anything). Looks like neither shellescape nor quotemeta are documented in the guide.