Comments on XDG Base Directory shell scripting tutorial

Be civil and read the entire article first. This is not a support forum. Comments from new contributors are moderated. English only.

Leave a comment

Required. Optional. E.g. your homepage, Twitter. or Email required unless anonymous. Not published or shared. Reuse to be recognized as the same commenter.
Plain-text only. Begin lines with a > character to quote.

Your script appears to be broken - one fix involves using the `:` builtin:

```sh

: XDG_CACHE_HOME:="$HOME/.cache"

```

But, a different technique is required since these variables need to be exported, as you mention.

Under that, it would be an improvement to make the script idempotent, quote the directories, and use lowercase variable names:

```sh

mkdir -p "$cache_dir" ...

```

This blog appears near the top of search results, so I think other people will benefit from these improvements.

Samueru

Thank you very much, I was doing a bunch of if conditions for each XDG variable when it was much simpler.