From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122663 invoked by alias); 26 Dec 2017 18:54:20 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 122653 invoked by uid 89); 26 Dec 2017 18:54:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=intact, WORKS X-HELO: mail-lf0-f50.google.com Received: from mail-lf0-f50.google.com (HELO mail-lf0-f50.google.com) (209.85.215.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Dec 2017 18:54:18 +0000 Received: by mail-lf0-f50.google.com with SMTP id j124so40325034lfg.2 for ; Tue, 26 Dec 2017 10:54:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=OvWVsTM+XpATRlmusDQBNmFgT862cfS0ckM+4l4vY7w=; b=eN9f+F6CmqfoDj3Ad00/o6NHf/euhmSjkwMOngoTSSFbE5fcKRVamhaFrPYH4C4pN+ MDXsLKDUqjx+iZPF+43O/Z6KRlerb3VVLC4JIree3demviZBOl9O/axkNdeY2N9kxkaN FKXEuhj4I6xYiYTHjspgdZyGL5aHfgWca7MaBgHiKKewq3GZtlWBCwYSGR5QPW4+6wz5 FvynRl49LAlmBsmxfM8nHoYdERU7gY5IKvUP8fYYoOe9UzZa0tQcxRO6ivWPFEd3m+Cw LnD8P/ovzlPWXI1IxhqlGy0aPKBpVSCfgwl7KINXHxXKF/yGwHPJ/PxIsYkUos4f0OSB Eb1w== X-Gm-Message-State: AKGB3mKRmFwDLuaF/8j6ABw1OjnlpS/RcY8C4hII8xyjnTWODhN1okfI GQJ/8/Lla8uip5FiUzVX58ERMk2cGUEv7dtbYbNDMhnh X-Google-Smtp-Source: ACJfBoubc4gfdpjvkgrtFyHjteKX7bi3iJpQexamN3sobF+UVb9Ak6G4d0xwq5RyCsz7ZsKevnKuzYlAZNZNkAFPPJs= X-Received: by 10.46.84.65 with SMTP id y1mr15629638ljd.74.1514314455188; Tue, 26 Dec 2017 10:54:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.167.77 with HTTP; Tue, 26 Dec 2017 10:54:14 -0800 (PST) In-Reply-To: <5a428a47.d0179d0a.4c14c.fe57@mx.google.com> References: <5a4087c1.cdebca0a.a4e97.8eb3@mx.google.com> <5a428a47.d0179d0a.4c14c.fe57@mx.google.com> From: Dave Caswell Date: Tue, 26 Dec 2017 19:41:00 -0000 Message-ID: Subject: Re: Run command in new window To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00261.txt.bz2 > and for some reason any spaces must be quoted - not escaped - these work: > > cygstart bash -c '"echo 1;read"' > cygstart bash -c "'echo 1;read'" > > these fail: > > cygstart bash -c 'echo\ 1;read' > cygstart bash -c "echo\ 1;read" The '-v' option to cygstart gives the key to understanding this by showing what actually gets passed along by cygstart. WORKS: davec@SodiumWin ~ $ cygstart -v bash -c " ' echo TT; sleep 5 ' " ShellExecute(NULL, "(null)", "bash", "-c ' echo TT; sleep 5 ' ", "(null)", 1) The quotes surrounding the argument to -c get passed along to the executed bash. WORKS: davec@SodiumWin ~ $ cygstart -v bash -c '"echo 1;read"' ShellExecute(NULL, "(null)", "bash", "-c "echo 1;read"", "(null)", 1) Same here, the echo and read are both contained in one argument to -c. DOES NOT WORK davec@SodiumWin ~ $ cygstart -v bash -c 'echo\ 1;read' ShellExecute(NULL, "(null)", "bash", "-c echo\ 1;read", "(null)", 1) Without the quotes to group the echo and read together, when the executed bash breaks the line up into words, the -c only sees echo\ as its command. WORKS: davec@SodiumWin ~ $ cygstart -v bash -c \'echo 1\;read \' ShellExecute(NULL, "(null)", "bash", "-c 'echo 1;read '", "(null)", 1) By escaping the quotes and semicolon so they get passed along intact, the executed bash also gets an intact command string. Does this help at all? -- 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