skonfig / base

explorer and types for general use
GNU General Public License v3.0
4 stars 4 forks source link

__link: fix type explorer for symbolic links with missing source #68

Closed sideeffect42 closed 1 year ago

sideeffect42 commented 1 year ago

When using __link to create a symbolic link with a non-existing --source (e.g. one being created by a cron job), the type explorer will always (incorrectly) report none, making the type recreate the symbolic link on every run.

This is because test ! -e returns 0 for a symbolic link whose link destination does not exist. So to fix the behaviour, we test -h first, detecting it is a symbolic link.

I also did a little simplification in the state explorer: we don't need to cd in the --type symbolic case, because the sources are compared as strings, not as actual file system paths.