From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11183 invoked by alias); 6 Dec 2016 04:59:41 -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 10535 invoked by uid 89); 6 Dec 2016 04:58:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.1 required=5.0 tests=BAYES_50,CYGWIN_OWNER_BODY,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy=disaster, glenn, Glenn, sk:briani X-HELO: esa1.dell-outbound.iphmx.com Received: from Unknown (HELO esa1.dell-outbound.iphmx.com) (68.232.153.90) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Dec 2016 04:58:27 +0000 Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa1.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2016 22:58:19 -0600 From: "Gluszczak, Glenn" Received: from mailuogwdur.emc.com ([128.221.224.79]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2016 10:58:18 +0600 Received: from maildlpprd52.lss.emc.com (maildlpprd52.lss.emc.com [10.106.48.156]) by mailuogwprd51.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id uB64wGsH028778 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 5 Dec 2016 23:58:17 -0500 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd51.lss.emc.com uB64wGsH028778 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd51.lss.emc.com uB64wGsH028778 Received: from mailusrhubprd01.lss.emc.com (mailusrhubprd01.lss.emc.com [10.253.24.19]) by maildlpprd52.lss.emc.com (RSA Interceptor); Mon, 5 Dec 2016 23:55:48 -0500 Received: from MXHUB102.corp.emc.com (MXHUB102.corp.emc.com [10.253.58.15]) by mailusrhubprd01.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id uB64w0hM018574 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 5 Dec 2016 23:58:00 -0500 Received: from MX204CL04.corp.emc.com ([fe80::5c2f:a83c:a32d:4b29]) by MXHUB102.corp.emc.com ([::1]) with mapi id 14.03.0266.001; Mon, 5 Dec 2016 23:57:59 -0500 To: "Brian.Inglis@SystematicSw.ab.ca" , "cygwin@cygwin.com" Subject: RE: sh -c and newline Date: Tue, 06 Dec 2016 04:59:00 -0000 Message-ID: <91DCAC3CB99C724EB365BB64677FBE7B102A65@MX204CL04.corp.emc.com> References: <91DCAC3CB99C724EB365BB64677FBE7B1007BC@MX204CL04.corp.emc.com> <91DCAC3CB99C724EB365BB64677FBE7B100851@MX204CL04.corp.emc.com>,<0ac85458-01dd-7f0f-d6ad-25cbb672d785@SystematicSw.ab.ca> In-Reply-To: <0ac85458-01dd-7f0f-d6ad-25cbb672d785@SystematicSw.ab.ca> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd01.lss.emc.com X-RSA-Classifications: public X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00041.txt.bz2 Ah I never knew about ^. Thanks a lot for that tip. I'll try it out tomor= row. Yeah I work in the backup/data protection division here, ________________________________________ From: cygwin-owner@cygwin.com [cygwin-owner@cygwin.com] on behalf of Brian = Inglis [Brian.Inglis@SystematicSw.ab.ca] Sent: Monday, December 05, 2016 6:30 PM To: cygwin@cygwin.com Subject: Re: sh -c and newline On 2016-12-05 14:11, Gluszczak, Glenn wrote: > On 2016-12-05 15:04, Brian Inglis wrote: >> On 2016-12-05 12:38, Gluszczak, Glenn wrote: >>> I can't seem to get sh -c to recognize newline. Tcsh -c works. >>> I'm using echo as an example but I'm actually trying to build a >>> here-document. >>> %%%sh -c "echo \nhello" >>> nhello >>> %%%sh -c "echo \\nhello" >>> nhello >>> %%%sh -c "echo \\\nhello" >>> \nhello >>> %%%tcsh -c "echo \nhello" >>> nhello >>> %%%tcsh -c "echo \\nhello" >>> \nhello >>> %%%tcsh -c "echo \\\nhello" >>> hello >> Your login shell is scanning and interpreting escapes in the input, then= the subshell you are running, so you need to quote \n to let echo see it. = Builtin echo does not recognize escapes without -e. >> You can use echo -e, or $ prefix a single quoted string to have the shel= l interpret the escape sequence. >> $ sh -c "echo -e '\nhello'" >> >> hello >> $ sh -c "echo $'\n'hello" >> >> hello >> $ sh -c "echo $'\nhello'" >> >> hello > Thank you for the answer Brian. I was trying to show a problem with a > HERE document and used echo but it is not the exact same issue. > I forgot about the order of substitution; my original issue is > similar. > In CMD, you can't have multiple lines for sh -c but in shell you can > sh -c "cat -< hello > EOF" > Turns out the newlines are being sent, but CMD thinks a command is > only on one line. Perhaps there is a way to specify multiple lines in > a cmd prompt. Use can use & in cmd like ; in bash and && works the same in both; with conditional and loop constructs in cmd, you can use: if|for ... ( command1... command2... ) across multiple lines, and you can use ^ in cmd like \ in bash for both line continuation and escaping. Learned this stuff porting some shell scripts to cmd for use by folks on backup or home desktops during Disaster Recovery and migration backup tests, so they could download and prep data locally, in case any of the Unix or file servers, or network, to do this automatically and transparently were inaccessible. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada -- 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 -- 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