X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D31A1385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1678464959; bh=+AInNHjSYS3hBR10CR068p2V7W5tdWl1uTu93JfsNzo=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Ap8Ekud98DnhRowtxYVTwnMY9dTOqxJ4BBF8iNUviYhbA57kHOWtfljY9oHsPCPFQ wIBTNbxhOWzW2siE4VEAUzWq6ZzYD/N4ZHOVmmQZe7ku1Vbpkfgq/tdEta051UIU6H lm3Wxtef9IEsHwgY3f9nMG32fuSn5sUv0J8L08kw= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE5F73858D38 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 Subject: Re: General scripting issues vs. Linux Content-Language: en-CA To: cygwin AT cygwin DOT com References: <63cccff3-9487-3588-5dd8-e49499882280 AT cornell DOT edu> Organization: Inglis In-Reply-To: <63cccff3-9487-3588-5dd8-e49499882280@cornell.edu> 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 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Brian Inglis via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Brian Inglis Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 32AGGNss019963 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 -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple