From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28603 invoked by alias); 16 Jul 2014 14:14:52 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18947 Received: (qmail 25281 invoked from network); 16 Jul 2014 14:14:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=cpicQKoBWI/3BS2mJc7ooCsIMeERzwQAVYktt5n3350=; b=icogPfGJPXUC+F0w0esWXeiywsX1B1bCdJyMSHZAu5LYfQjRwS33R+1ojl4r862YAL qz4nHht33bu15o/xu80uu07wT7yu7QiNxYWTt3HGYkc4EE5/mVQ2Mx3EGeC/7WAKOOzc RD8i3F4R6sBx8+nhdqD342D9DRvOa5rPGPy5Qeiod//l4BBpXeEeGailob7lFjb+JFAT w5Kzljr4zi9Z3KOwqFIh1ht2rH9w9ydWRVetBMvCgXroiOmRGp5ajcugKHiVEYOrrR4J XuDO/sS8Y/jw7UCUMAnX6wSMhlINC8d50Ta6BzTvqYeD7nA7I27V30KdXrJ/fz4wbECH ryXg== X-Gm-Message-State: ALoCoQlHOX6W3Df2ptm7ubpocoBGtmYPdRk61ycu8JHSCWkFqvrUvs4dzlBtpgtgXkwht8HKIJWd MIME-Version: 1.0 X-Received: by 10.221.25.210 with SMTP id rj18mr4208803vcb.5.1405520082600; Wed, 16 Jul 2014 07:14:42 -0700 (PDT) In-Reply-To: <1405517211.83024.YahooMailNeo@web172702.mail.ir2.yahoo.com> References: <1405517211.83024.YahooMailNeo@web172702.mail.ir2.yahoo.com> Date: Wed, 16 Jul 2014 07:14:42 -0700 Message-ID: Subject: Re: Check write permissions From: Kurtis Rader To: Sepp Tannhuber Cc: "zsh-users@zsh.org" Content-Type: multipart/alternative; boundary=001a113643183f9e0204fe502565 --001a113643183f9e0204fe502565 Content-Type: text/plain; charset=UTF-8 If you're doing it in the context of a var assignment why not just my_variable=''; [[ -w . ]] || my_variable='my_value' You could also use glob flags but that requires creating an array var x=( .(N^w:s/./my_value/) ) On Wed, Jul 16, 2014 at 6:26 AM, Sepp Tannhuber wrote: > I am looking for an easy solution to monitor in my prompt whether PWD > has write permissions or not. I use something like this: > my_variable="${$([[ -w $PWD ]] || echo 0):+my_value}" > > This sets $my_variable to my_value when there are no write permissions. > Although this works, it looks very complicated, especially with the echo > command. > And I am wondering if there is a more elegant solution. Does anybody have > an idea? -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --001a113643183f9e0204fe502565--