Custom Command File with spaces generates error
Describe the bug When using a custom command file with spaces in the path, in bash, it looks like swift dialog tries to create/verify the existence of the file before it writes any updates to it. If the path contains a space the shell will display the following error messages: touch: /Path up until first space: Permission denied -and- "ERROR: Failed to get file creation date: The file “FILE NAME” couldn’t be opened because there is no such file. Echoing out the path to the command
When the space is removed from the path to the command file these errors do not appear. This does not affect the command file being written to and dialog updates being processed appropriately. This happens if the path is quoted or the space in the path is escaped.
To Reproduce Steps to reproduce the behavior:
-
In bash (script or in the shell window) create a path to a custom command file with a space in its path and assign it to a variable (the folder /tmp/swift dialog folder already exists and is world writeable) eg: CSVCommandFile=$(mkdir "/tmp/swift dialog/swiftdialog.log") -or- CSVCommandFile=$(mkdir /tmp/swift\ dialog/swiftdialog.log)
-
Run a dialog window from a bash shell/script specifying this command file via a quoted variable eg dialog --commandfile "$CSVCommandFile" --jsonfile /path to file
-
The error "touch: /tmp/swift : Permission denied" is displayed in the shell
-
Send an update to the command file via the quoted variable. eg echo "button1: enable" >> "$CSVCommandFile"
-
The error "ERROR: Failed to get file creation date: The file “swiftdialog.log” couldn’t be opened because there is no such file." is displayed in the shell
-
The dialog window is updated successfully
Expected behavior A command file with a valid and accessible path should generate no errors.
Desktop (please complete the following information):
- macOS 14.4.1
- swiftDialog version 2.4.0.4750
I can recreate this in both 2.4.2.4755 and 2.5.0.4757
Does not appear to affect functionality, just results in errors being generated.
#!/bin/zsh --no-rcs
# shellcheck shell=bash
dialogCommandFile=$(mktemp "/var/tmp/Command File With Space.XXXXXXXX")
# execute a dialog command
function dialog_command(){
/bin/echo "$@" >> "$dialogCommandFile"
sleep .1
}
dialog --title "Testing Whitespace" --message "This is a test" --button1disabled --button1text "disabled" --commandfile "$dialogCommandFile" &
sleep 3
dialog_command "button1: enable"
Results:
ERROR: Failed to get file creation date: The file “Command%20File%20With%20Space.lcVKLsV0” couldn’t be opened because there is no such file.