importpw / import

`import` is a simple and fast module system for Bash and other Unix shells
https://import.sh
MIT License
338 stars 10 forks source link

Default $IMPORT_CACHE creates $HOME folder bloat #36

Closed emiliovesprini closed 4 years ago

emiliovesprini commented 4 years ago

Peppering $HOME with hidden files and folders is a generally agreed upon anti-pattern (check here or here for more info) commonly fixed with the help of the XDG Base Directory spec.

A fix may be as easy as something like

-       local cache="${IMPORT_CACHE-${HOME}/.import-cache}"
+       local cache="${HOME}/.cache/import"
+       [ -n "$XDG_CACHE_HOME" ] && local cache="${XDG_CACHE_HOME}/import"
+       [ -n "$IMPORT_CACHE" ] && local cache="$IMPORT_CACHE"

but there's the obvious issue of backwards compatibility, so maybe this should be closed as wontfix.

vardrop commented 4 years ago

@emiliovesprini *$IMPORT_CACHE, you misspelled it in the title as $IMPORT_CASH

emiliovesprini commented 4 years ago

Fixed, thanks.

TooTallNate commented 4 years ago

Ya, I'd like to support the XDG Base Directory spec. Pull request welcome if you feel like taking a stab at it, your diff looks pretty good to me already!

emiliovesprini commented 4 years ago

So you don't mind me changing the default dir? Be right back.

emiliovesprini commented 4 years ago

Having trouble making the tests pass, might take me a bit longer.

TooTallNate commented 4 years ago

Note that Windows and macOS have different conventions for their cache dirs. import should use these by default, if $XDG_CACHE_HOME is not defined:

TooTallNate commented 4 years ago

but there's the obvious issue of backwards compatibility, so maybe this should be closed as wontfix.

Backwards compatibility isn't a concern in this case, since a cache directory by its nature is ephemeral - it would just have to re-download the cache files into the new directory.

TooTallNate commented 4 years ago

Open up the pull request anyways, we can work through the errors there.

On Fri, Jul 17, 2020 at 2:44 PM Emilio Vesprini notifications@github.com wrote:

Having trouble making the tests pass, might take me a bit longer.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/importpw/import/issues/36#issuecomment-660350075, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARMWCOZN5RWMYSCABGFW3R4DA3NANCNFSM4O6Q4KCQ .

emiliovesprini commented 4 years ago

Sorry I left you guys hanging, I got busy with school.