swc-windows-installer.sh: Use '~' in ~/nano.rc includes
authorW. Trevor King <wking@tremily.us>
Wed, 12 Mar 2014 23:56:19 +0000 (16:56 -0700)
committerW. Trevor King <wking@tremily.us>
Thu, 13 Mar 2014 00:10:25 +0000 (17:10 -0700)
On Wed, Mar 12, 2014 at 04:44:31PM -0700, Ethan White wrote [1]:
> Got it. We just need to change the `/c/Users/River/` in the include
> statements to `~/` and everything works great!

I also replaced an:

  if [ ... ]

condition with:

  if test ...

to match the rest of the script.

The underscore prefixes in the string-equality test are to avoid miss
interpretation in the pathological case that RCPATH starts with '!' or
some such.  It's hard to imagine how this could happen with the
current script, but... safety first ;).

[1]: https://github.com/swcarpentry/bc/pull/357#issuecomment-37483149

swc-windows-installer.sh

index 84952b7f74cc7fd4ebfe9e13f1edee7a3a47c72f..5ad51e991244ecf68f3ecdab683c8c0ee6dc6313 100755 (executable)
@@ -91,10 +91,15 @@ install_nanorc()
                '03233ae480689a008eb98feb1b599807' \
                "${INSTALL_DIRECTORY}" \
                --strip-components 1 &&
-       if [ ! -f ~/nano.rc ]
+       HOME=~
+       if test ! -f ~/nano.rc
        then
                for RCPATH in "${INSTALL_DIRECTORY}"/doc/syntax/*.nanorc
                do
+                       if test "_${RCPATH:0:${#HOME}}" = "_${HOME}"
+                       then
+                               RCPATH="~${RCPATH:${#HOME}}"
+                       fi
                        echo "include ${RCPATH}" >> ~/nano.rc
                done
        fi