0

I'm struggling to fix the following shellcheck warning, because it would require nested quotes:

here=$(dirname $(realpath "$0" 2> /dev/null || grealpath "$0"))
               ^-- SC2046 (warning): Quote this to prevent word splitting.

How could I write this in a safe way with everything correctly quoted?

PiRK
  • 893
  • 3
  • 9
  • 24
  • 7
    Double quotes and `$(...)` can be nested without problems. – choroba May 09 '23 at 15:38
  • 2
    Even with correct quoting, the code in the question won't work in general. See [BashFAQ/028 (How do I determine the location of my script? ...)](https://mywiki.wooledge.org/BashFAQ/028) (particularly the [Why $0 is NOT an option](https://mywiki.wooledge.org/BashFAQ/028#Why_.240_is_NOT_an_option) section). – pjh May 09 '23 at 17:06

0 Answers0