X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=gYGY ZOLYjVqJAZ98yMwqKmqBEWRpsn/7fMSzU+Tlb/bDytsynJkwx7n3Rc8VjomqAqlt eTRyDt+bQ57JFDYWvGDW1xXbDfC4ZBIxl21YZW+6s/eeXEMxLzq/DGe1kDnmGmuc e1VSSBQNCMrHFrcthtDj8jgOKYmmixHhJZOtUOM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=k5MsP6esx8 8Q+TVyvWueA7Z8exo=; b=YQMnxgItJrvhxRkOHCYKl8tPh4EVPXnXbT/huB8bVb fpR3PiHvVlS1Vnjb/N875xmhemZA3NzLudYjhL649bR+koDS33UqzUPLPEQkLCO4 6HMmoBVCd0QWmo/bMagGpfCWymtIlSETg/M6UvqjpJpU7cGWOyQOnUOOiDKQi3x6 M= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=U*e60iporpd8lec, e60iporpd8lec AT guerrillamail DOT com, D*guerrillamail.com, 45ownu X-HELO: mail-io0-f194.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=83ItOG7MrQLV972v1BQCOv28Z/LVe9nqd5UIoZ6SlC4=; b=hVhwSdGD8VWx3jftO0Ygp71JMg+NAjv/pK3Oxv0d5o1fmMEcby8GGhSP/KfrzXdFjD v5yWQaLBKeUZaTr+uUlH6rFkGCQ/X9PELc7FsJ/KKU1TAGTNAxBBdSakGY2+OBLpoRfc +BDhpIOnYNZYP8nHP7kDC+SIrGxcMg51Lls+UrYqnjSEZwXSxeEaqvIjkgbppbMJ2sqw gE8fAQylmQFED/0GaHLQHU2qnziTsSNcJWMEDT2u8+jUzOTacFKakJfyWjhrNfmwDbCh GCEsXqjfTZdZrDT5xyj3Q1u+QcPEJ3GDGqUVt1VQIajYoFwPFyMfUAMIMjOTrYVuCb29 l95Q== X-Gm-Message-State: AEkooutY+iGmTsoZYLUIi1HIqVJSh4+GE5Te7UT2IHQcD9eRuCZVrJzW43nJpK7FAVWjsQ== X-Received: by 10.107.12.34 with SMTP id w34mr43740058ioi.171.1469711663971; Thu, 28 Jul 2016 06:14:23 -0700 (PDT) Date: Thu, 28 Jul 2016 14:14:17 +0100 From: Adam Dinwoodie To: cygwin AT cygwin DOT com Subject: Re: <> returns syntax error Message-ID: <20160728131417.GJ2345@dinwoodie.org> References: <51777330c6d999e10af5937cf2e06ea6fe5 AT guerrillamail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51777330c6d999e10af5937cf2e06ea6fe5@guerrillamail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On Thu, Jul 28, 2016 at 12:55:43PM +0000, 45ownu+e60iporpd8lec AT guerrillamail DOT com wrote: > Steps to reproduce (I cannot update cygwin on this server, but it also happen on 2.5.2(0.297/5/3)): > Main window: > $ uname -r > 1.7.25(0.270/5/3) > $ expr 100 * 100 > 10000 > > --------------- > Other window: > $ $ uname -r > 1.7.25(0.270/5/3) > $ HOST=myhostname > $ echo 'whatever' > $HOST.txt > > --------------- > Main window: > $set -xv > $expr 100 * 100 > + expr 100 myhostname.txt 100 > syntax error > > ------------------------------------------------ > > When this happen I can only fix by rebooting the server, which is obviously unideal! > Here my questions: > 1) How can I reset cygwin to the initial behaviour without rebooting? > 2) why does this happen? how to prevent this? This is working as intended: '*' is a shell glob character, so Bash will attempt to expand it. In the first case, you're evidently in a directory that contains no files or directories (excluding ones that start with a '.'), so the glob doesn't expand and is left as-is. This means the `expr` command sees the arguments as you typed them: `100 * 100`. In the second case, you've created a file called myhostname.txt in this directory, so the '*' glob will expand to the list of matching file names, i.e. myhostname.txt. This means the `expr` command will see the arguments after the glob expansion, i.e. `100 myhostname.txt 100`. Run the following commands in a shell and you might see what's happening: mkdir tmp; cd tmp echo * touch file1 echo * touch file2 echo * touch file3 echo * See also https://en.wikipedia.org/wiki/Glob_(programming) You can disable this behaviour with `set -f`, or by escaping or quoting the '*' character (i.e. `expr 100 \* 100` or `expr 100 '*' 100`). HTH Adam -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple