diff --git a/client/powerline.c b/client/powerline.c index f53e3457..d6858770 100644 --- a/client/powerline.c +++ b/client/powerline.c @@ -42,12 +42,12 @@ void do_write(int sd, const char *raw, size_t len) { } } -#ifdef __APPLE__ -# define ADDRESS_TEMPLATE "/tmp/powerline-ipc-%d" -# define A -#else +#ifdef __linux__ # define ADDRESS_TEMPLATE "powerline-ipc-%d" # define A +1 +#else +# define ADDRESS_TEMPLATE "/tmp/powerline-ipc-%d" +# define A #endif #define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4) diff --git a/client/powerline.py b/client/powerline.py index 78403887..28492c15 100755 --- a/client/powerline.py +++ b/client/powerline.py @@ -26,9 +26,7 @@ if len(sys.argv) < 2: print('Must provide at least one argument.', file=sys.stderr) raise SystemExit(1) -platform = sys.platform.lower() -use_filesystem = 'darwin' in platform -del platform +use_filesystem = not sys.platform.lower().startswith('linux') if sys.argv[1] == '--socket': address = sys.argv[2] diff --git a/client/powerline.sh b/client/powerline.sh index b112ec21..b8e37956 100755 --- a/client/powerline.sh +++ b/client/powerline.sh @@ -1,6 +1,22 @@ #!/bin/sh -test "${OSTYPE#darwin}" = "${OSTYPE}" && darwin=n || darwin=y +use_filesystem=1 +darwin= +if test -n "$OSTYPE" ; then + # OSTYPE variable is a shell feature. supported by bash and zsh, but not + # dash, busybox or (m)ksh. + if test "${OSTYPE#linux}" '!=' "${OSTYPE}" ; then + use_filesystem= + elif test "${OSTYPE#darwin}" ; then + darwin=1 + fi +elif which uname >/dev/null ; then + if uname -o | grep -iqF linux ; then + use_filesystem= + elif uname -o | grep -iqF darwin ; then + darwin=1 + fi +fi if test "$1" = "--socket" ; then shift @@ -8,13 +24,16 @@ if test "$1" = "--socket" ; then shift else ADDRESS="powerline-ipc-${UID:-`id -u`}" - test "$darwin" = y && ADDRESS="/tmp/$ADDRESS" + test -n "$use_filesystem" && ADDRESS="/tmp/$ADDRESS" fi -if test "$darwin" = y; then +if test -n "$darwin" ; then ENV=genv else ENV=env +fi + +if test -z "$use_filesystem" ; then ADDRESS="abstract-client:$ADDRESS" fi diff --git a/scripts/powerline-daemon b/scripts/powerline-daemon index 62cb35f3..7e78b6b0 100755 --- a/scripts/powerline-daemon +++ b/scripts/powerline-daemon @@ -24,8 +24,7 @@ from powerline.commands.daemon import get_argparser as get_daemon_argparser is_daemon = False -platform = sys.platform.lower() -use_filesystem = 'darwin' in platform +use_filesystem = not sys.platform.lower().startswith('linux') address = None pidfile = None