diff --git a/guile-stash.scm b/guile-stash.scm index 37a6da0..3c756e2 100644 --- a/guile-stash.scm +++ b/guile-stash.scm @@ -121,18 +121,17 @@ (else (display (color-message "No valid action selected, no changes made.\n" red-text))))) - (define (create-symlink source target) "Create a symlink for the source directory at the target location." (let ((target-symlink-path (string-append target "/" (basename source)))) - (if (file-exists? target-symlink-path) ; Checks if the path exists (file, directory, or symlink) - (handle-conflicts target-symlink-path source) ; Handle existing path - (begin - (catch 'system-error - (lambda () (symlink source target-symlink-path) - (display (color-message (string-append "Symlink created for: " target-symlink-path " -> " source "\n") green-text))) - (lambda args - (display (color-message "File exists. Unable to create symlink.\n" red-text)))))))) + (if (file-exists? target-symlink-path) + (handle-conflicts target-symlink-path source) ; Call conflict handler if file exists + (catch 'system-error + (lambda () + (symlink source target-symlink-path) + (display (color-message (string-append "Symlink created for: " target-symlink-path " -> " source "\n") green-text))) + (lambda args + (display (color-message "Error creating symlink.\n" red-text))))))) (define (main args) "Main function to parse arguments and initiate processing."