zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: zsh array subscripting with ksh comp behaviour
Date: Sat, 23 Aug 2014 12:24:00 -0700	[thread overview]
Message-ID: <140823122400.ZM23622@torch.brasslantern.com> (raw)
In-Reply-To: <20140823190313.0286796f@pws-pc.ntlworld.com>

On Aug 23,  7:03pm, Peter Stephenson wrote:
} 
} Hence you can test directly for this feature.  As long as the shell
} isn't old enough that the special parameters used by the new completion
} system are absent,
} 
}   zmodload -i zsh/parameter
}   print ${+options[kshzerosubscript]}   

It's too bad that [[ -o there_is_no_such_option ]] is a critical error
rather than returning some kind of falsehood, but you can always test
in any version of the shell with

    if ( [[ -o kshzerosubscript ]] ) >&/dev/null
    then print KSH_ZERO_SUBSCRIPT
    else print not KSH_ZERO_SUBSCRIPT
    fi

Unfortunately this isn't all you need in this case, because the old
behavior occurs when EITHER (a) the option doesn't exist OR (b) the
option is set.

So you end up with something like

    if ( setopt kshzerosubscript ) >&/dev/null &&
       [[ ! -o kshzerosubscript ]]
    then print New zero subscript behavior
    else print Old zero subscript behavior
    fi


      reply	other threads:[~2014-08-23 19:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 13:54 Jerry Rocteur
2014-08-21 14:47 ` Roman Neuhauser
2014-08-21 19:47 ` Bart Schaefer
2014-08-23 18:03   ` Peter Stephenson
2014-08-23 19:24     ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=140823122400.ZM23622@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).