'Run Shell Script' does not work in Automator
I've upgraded to MacOS Monterey and my old Automator workflow scripts no longer work.
I've converted them to 'Quick Actions', but they don't work.
My workflow scripts use 'run shell script', which take the selected files or folders and makes a tarball.
I echo date, variables, commands, and errors to a file to log what's going on.
It's as if tar cannot find the files. Below is the code:
exec 3>~/output.txt
for f in "$@"
do
date +%+ >&3
echo "\$f is '${f}'" >&3
PARENT_DIR="$(dirname "$f")"
ITEM_NAME="$(basename "$f")"
TAR_NAME=$(printf '%s' "${ITEM_NAME/ /-}" | tr [:upper:] [:lower:])
echo "\$PWD is '${PWD}' before CD" >&3
cd "$PARENT_DIR" 2>&3
tar -czf "${TAR_NAME}.tar.gz" --no-xattrs --options='gzip:compression-level=9' "$ITEM_NAME" 2>&3
echo "\$PARENT_DIR is '${PARENT_DIR}'" >&3
echo "\$ITEM_NAME is '${ITEM_NAME}'" >&3
echo "\$TAR_NAME is '${TAR_NAME}'" >&3
echo "\$PWD is '${PWD}' after CD" >&3
done
exec 3>&-
Here is what's printed in ~/output.txt:
Wed Dec 8 12:07:03 PST 2021
$f is '/Users/neal/Documents/Current Work/Interim Billboard/Previous Versions'
$PWD is '/Users/neal' before CD
tar: Previous Versions: Cannot stat: Bad file descriptor
tar: Error exit delayed from previous errors.
$PARENT_DIR is '/Users/neal/Documents/Current Work/Interim Billboard'
$ITEM_NAME is 'Previous Versions'
$TAR_NAME is 'previous-versions'
$PWD is '/Users/neal/Documents/Current Work/Interim Billboard' after CD
This is what I expected, except for the tar errors. The result is an empty tarball.
I have set 'Full Disk Access' to Teminal.app, Automator.app, and even Shortcuts.app.
This code did work in MacOS High Sierra.
Any ideas as to what is going on, or how I can fix this?
iMac 27″, macOS 12.0