I am currently writing a small setup script for a Linux application that needs the user to edit a configuration file before the application is started. I've chosen to make the script simply open the configuration file in Nano, and resume the script afterwards. I do, however, need to detect whether the user saved the changes (to then continue starting the application), or whether he discarded them (which would indicate the user doesn't want to continue).I have already checked whether this is possible with the returned exit code from Nano, and it apparently isn't - it always returns 0 even if the changes were discarded. Is there another way to figure out whether the file was changed and saved, or will I have to do this in an entirely different way?
How do I detect whether changes in nano were discarded or saved?
bash;scripting;nano
You can use the stat command to check the file's modification time before and after nano.  Something like:oldtime=`stat -c %Y $filename`nano $filenameif [[ `stat -c %Y $filename` -gt $oldtime ]] ; then  echo $filename has been modifiedfiOf course, this won't detect whether nano modified the file, or some other program did, but that could be considered a feature.  (You can use some other program to edit the file, and then exit nano without saving.) 