From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) by sourceware.org (Postfix) with ESMTPS id DE5F73858D38 for ; Fri, 10 Mar 2023 16:15:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE5F73858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=Shaw.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=shaw.ca Received: from shw-obgw-4002a.ext.cloudfilter.net ([10.228.9.250]) by cmsmtp with ESMTP id aZDcp94SBjvm1afPApTNyo; Fri, 10 Mar 2023 16:15:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=shaw.ca; s=s20180605; t=1678464940; bh=Jhx80/fuKfXNlowvFjXuvdbXSpqXUzMNLv923Nk59A4=; h=Date:Reply-To:Subject:To:References:From:In-Reply-To; b=XgKNs0dsvavHvwH1feRnoJLsdESVhRiSEmotJYYu57O9Go+1f6qwfwk7HoZ3i7kXD C+YdHgCYSi2a6rJfk0ttTaEHLpMQB4Sn4FJFQ7qHyNoFq7lGMCNeJVNTxLvjVesrlJ qAuf/sQkGKRhE1HBdOhhDAaIwSDSB/EqORqUXeWNZbmO5jqtffd42MtrVRTkoHn+eE OpMQdA5KtUanZd1W+lqIsGQ8BhHNudEYobbYcVqxPDL8AN7pK2ZJ+cnikiQqy+YU1J 8W63ztcLYaNW4zGrAsTXH/trnr/zxYK19lpVsvozqGVSk+jOc0ugZM3Rg0gb5Lc4kb zf8guSDQRsvdg== Received: from [10.0.0.5] ([184.64.102.149]) by cmsmtp with ESMTP id afP9pJOayyAOeafP9pR9Kr; Fri, 10 Mar 2023 16:15:40 +0000 X-Authority-Analysis: v=2.4 cv=e5oV9Il/ c=1 sm=1 tr=0 ts=640b57ac a=DxHlV3/gbUaP7LOF0QAmaA==:117 a=DxHlV3/gbUaP7LOF0QAmaA==:17 a=IkcTkHD0fZMA:10 a=w_pzkKWiAAAA:8 a=uPZiAMpXAAAA:8 a=3DWQ6W_faQMF3dDoTrUA:9 a=QEXdDO2ut3YA:10 a=B7CIAJWMF7gA:10 a=ZIGPnEnQmisA:10 a=vmOwH9HAGyUA:10 a=FBNtmh7_lDcA:10 a=HwLhsGZx5EYA:10 a=sRI3_1zDfAgwuvI8zelB:22 Message-ID: Date: Fri, 10 Mar 2023 09:15:39 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Reply-To: cygwin@cygwin.com Subject: Re: General scripting issues vs. Linux Content-Language: en-CA To: cygwin@cygwin.com References: <63cccff3-9487-3588-5dd8-e49499882280@cornell.edu> From: Brian Inglis Organization: Inglis In-Reply-To: <63cccff3-9487-3588-5dd8-e49499882280@cornell.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfLUbGj9V5FyuKA4Ix7C0lQcXilCzyVZNAWlcA9YVs/AdPZXtf9us0uxhAnj/IYnPxj2UY2GMfVhHKeLdGVbdrVoy92NvRRWI1C9+48SMH+a/+z4TmzCY Bz0bZQ8j+NBadHQQcmmpjm5uFcAjHkQFJgHXN/TpgfOV3XznLuGnEBYg6QM/NCgJw3gIOZXLTQ2Vsg== X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-03-10 06:59, Ken Brown via Cygwin wrote: > On 3/10/2023 8:47 AM, Markus Becker via Cygwin wrote: >> I am quite an newby in Cygwin scripting and encountered several execution >> issues with bash scripts. For example, when i try to execute the following >> simple scriptfile "skript1.sh": >> # This is a testscript >> Statement="This is the testscript number 3" >> FILE="home/mbecker/Secure_Copy_Beispiel.txt" >> ls -l $FILE >> echo $Statement >> echo The file is $FILE >> i got these results: >> $ ./skript1.sh >> ls: cannot access 'home/mbecker/Secure_Copy_Beispiel.txt'$'\r\r': No such ^^^^^ >> file or directory >> This is the testscript number 3 >> The file is home/mbecker/Secure_Copy_Beispiel.txt >> or another results from a different script: >> $ ./skript7.sh >> ./skript7.sh: line 3: $'clear\r': command not found ^^^ >> Dr▒cken sie beliebige Tasten und dann return >> ': not a valid identifierd: `TASTE >> These are just two of several issues coming up with bash scripting in >> Cygwin. Maybe this is merely a corse problem with my platform >> understanding. But why is Cygwin calling errors when performing standard >> Linux bash commands? Is it due to a different syntax? Or is it even simpler? > It looks like your scripts have CRLF line endings. Utilities such as coreutils, gawk, grep, sed, etc. Cygwin packages had Cygwin tweaks removed in 2017 to be compatible with Linux and other platforms in handling '\r' before newlines, except for the single exception of Cygwin text mounts, where '\r' may be stripped if a program opens a file from that mount in text "t" mode, and may be added on writes to a file in text "t" mode on a text mount: https://www.cygwin.com/cygwin-ug-net/using-textbinary.html discussions: https://cygwin.com/legacy-ml/cygwin/2017-02/msg00152.html https://cygwin.com/legacy-ml/cygwin/2017-02/msg00188.html https://cygwin.com/legacy-ml/cygwin/2017-02/msg00189.html Install package dos2unix which conveniently strips the offending junk from your scripts and files e.g. d2u -k skript*.sh Install and use Cygwin editors and utilities, or check editor and utility settings to ensure they are not set to behave like Windows e.g. gvim set fileformat=unix termencoding=utf-8 fileencoding=utf-8 in your ~/.gvimrc ~/.vimrc ~/.virc ~/.exrc; emacs (set-buffer-file-coding-system 'mule-utf-8-unix) in ~/.emacs, type C-x C-q C-m f mule-utf-8-unix, or do the equivalent in more sophisticated initializations (auto)detecting file type, encoding, and format; for git config --global core.autocrlf = input, see: https://stackoverflow.com/questions/3206843/how-line-ending-conversions-work-with-git-core-autocrlf-between-different-operat -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry