From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 4CtJKBsoEWftQAAAqHPOHw:P1 (envelope-from ) for ; Thu, 17 Oct 2024 15:07:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 4CtJKBsoEWftQAAAqHPOHw (envelope-from ) for ; Thu, 17 Oct 2024 17:07:07 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1729177627; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=DRm3jtQ8lrh4vJoNudaEpn9/ZtI0TRaSgXrzeodZ07Q=; b=hz+TADqGFGa/3saTa1PqUU01uF4cMrbVjSbpy9siQKeKqnjGUzginsHARJ8R9BVGIXN20s 1wvVUrz+phsNXGTtSRheFbE8QYaeK1wEeoGVYqmuc3yAEWCwdSR8bRIDwoRRJoBvbroO8l Z8QJdCggHJ8Q9iCYNvv87xtE6zKCl+d67d8DR4xNv3DSCuDGPqbNF+on8zlvBj5BSuXo5y PQQE6VvRQSrAUih6Y9SKAQ/0SkTqkWEuqDJ1kHJMd/klvt77t+WPSCnYZIZk4ze6hNrREG 6kPkn1hm/CyPostIv64zYcAjpX0UU/ezykzi+nkr8YDu/LNqe3X1wVvnHhTY9Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1729177627; a=rsa-sha256; cv=none; b=Yho9yAICBdrlXwai3XkFmhHsnFyfwlxsfLfSvG1K2k3VunxTPk4DhJEsg/taywahPAxxGi Al4SMocYtCuyaFptQYp/HEQbA+XnD03jpItdn9dhkFoeyqWRDBn67bEIVkgvQrf1jmtrbx 7AXg9qC3rJKPJnjJMQS2jSdH5owPppggjvbyPEXzUzKP1zJP2YNt9n3uDZLwn38MdTp3Mz OgBs4mv8IdAAMOyYE7Yy5G4yJKZdEPSMx/ygOUVXiwSkXPZsA7njcOZy3/hXorhfxlVUJt 4qVDt7z3hAR/gJPEgkDQ7QSwlXGOMkN03dbhu9v5xHULt4xHttHnrXxdJi5k9A== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7CD578612D for ; Thu, 17 Oct 2024 17:07:06 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t1S51-0004Ik-RV; Thu, 17 Oct 2024 11:06:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1S4z-0004IG-Rm for emacs-orgmode@gnu.org; Thu, 17 Oct 2024 11:06:21 -0400 Received: from smtpout1.mo11.mail-out.ovh.ca ([51.161.45.253]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t1S4w-0008UZ-A5 for emacs-orgmode@gnu.org; Thu, 17 Oct 2024 11:06:21 -0400 Received: from mxplan1.mail.ovh.ca (unknown [10.111.38.32]) by mo11.mail-out.ovh.ca (Postfix) with ESMTPS id 4XTrkk4dPKzHpw8 for ; Thu, 17 Oct 2024 12:06:06 -0300 (ADT) Received: from morales.pe (54.39.251.57) by DAG2EX2.mxpca1.local (172.16.2.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 17 Oct 2024 11:06:05 -0400 X-OVh-ClientIp: 190.233.209.18 From: Rodrigo Morales To: Subject: Why Emacs shows ^M at the end of some lines in sh code blocks that use curl? Date: Thu, 17 Oct 2024 10:05:55 -0500 Message-ID: <87r08eepm4.fsf@morales.pe> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [54.39.251.57] X-ClientProxiedBy: DAG2EX2.mxpca1.local (172.16.2.12) To DAG2EX2.mxpca1.local (172.16.2.12) X-Ovh-Tracer-GUID: d7738ac3-6e31-4e5f-8aa2-6b6ce503bf7a X-Ovh-Tracer-Id: 2872733613283120663 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrvdehuddgkeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvffufffkgggtihesmhdtreertddttdenucfhrhhomheptfhoughrihhgohcuofhorhgrlhgvshcuoehrohgurhhighhoqdhmrghilhhinhhgqdhlihhsthhssehmohhrrghlvghsrdhpvgeqnecuggftrfgrthhtvghrnhepgfejteehueehtdfhffehieffueevieehgeeutdeiieelieejleekgffhvdeljeeunecuffhomhgrihhnpegrrhgthhhivhgvrdhishenucfkphepuddvjedrtddrtddruddpheegrdefledrvdehuddrheejpdduledtrddvfeefrddvtdelrddukeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomheprhhoughrihhgohdqmhgrihhlihhnghdqlhhishhtshesmhhorhgrlhgvshdrphgvpdhnsggprhgtphhtthhopedupdhrtghpthhtohepvghmrggtshdqohhrghhmohguvgesghhnuhdrohhrghdpoffvtefjohhsthepmhhouddupdhmohguvgepshhmthhpohhuth Received-SPF: pass client-ip=51.161.45.253; envelope-from=rodrigo-mailing-lists@morales.pe; helo=smtpout1.mo11.mail-out.ovh.ca X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: 1.49 X-Spam-Score: 1.49 X-Migadu-Queue-Id: 7CD578612D X-TUID: AViDtjnMG6jO --=-=-= Content-Type: text/plain I saved the contents of the code block below to the file =/tmp/a.org=. #+HEADER: :tangle /tmp/a.org #+BEGIN_SRC org ,#+HEADER: :tangle no ,#+HEADER: :results verbatim ,#+BEGIN_SRC sh curl --silent --request GET 'http://localhost:4891/posts' ,#+END_SRC ,#+HEADER: :tangle no ,#+HEADER: :results verbatim ,#+BEGIN_SRC sh curl --include --silent --request GET 'http://localhost:4891/posts' ,#+END_SRC ,#+HEADER: :tangle no ,#+HEADER: :results verbatim ,#+BEGIN_SRC sh seq 1 10 ,#+END_SRC #+END_SRC I started Emacs using the command shown below. #+BEGIN_SRC sh emacs -Q --eval "(require 'ob-shell)" /tmp/a.org #+END_SRC I evaluated the three =sh= code blocks in Emacs. Here's an screenshot that shows the content of the buffer =/tmp/a.org= after the three code blocks have been evaluated: https://archive.is/RnAD6 (edited for clarity: https://archive.is/IJzuc ) Note that the character "^M" is shown at the end of each line that contain response headers shown by curl (in curl, response headers are shown using the flag --include). Those who can't open the screenshot can refer to the code bock below, I have manually replaced the character '^M' with the string "^M" just so that you see what I am seeing in my computer. The character ^M is only shown for lines showing the response headers, not for lines showing the response body. #+BEGIN_SRC org ,#+HEADER: :tangle no ,#+HEADER: :results verbatim ,#+BEGIN_SRC sh curl --include --silent --request GET 'http://localhost:4891/posts' ,#+END_SRC ,#+RESULTS: ,#+begin_example HTTP/1.1 200 OK^M Server: Werkzeug/3.0.4 Python/3.10.12^M Date: Thu, 17 Oct 2024 14:57:28 GMT^M Content-Type: application/json^M Content-Length: 123^M Connection: close^M ^M [ { "title": "Title of post 1" }, { "title": "Title of post 2" }, { "title": "Title of post 3" } ] ,#+end_example #+END_SRC I then pressed =M-x shell RET= and executed the same commands from the sh code blocks. Here's an screenshot that shows the buffer =*shell*= after the three commands have been executed: https://archive.is/XDyIg (edited for clarity: https://archive.is/A8dkZ ) Note that the character "^M" is not shown at the end of each line, as happened when the same command was evaluated in an Org Mode code block. I wish those ^M were not shown in the sh code blocks in the Org Mode buffer. Does anyone know how to accomplish this behavior? You can find the file =/tmp/a.org= (after the three code blocks have been evaluated) attached in this message. ** Additional information Below you can find a simple Python application that you can use as an API to reproduce this behavior. The first code block below shows the command that you can run to initialize the virtual environment. The second code block shows the Flask application. The third code block below shows the command to run the Flask application. #+HEADER: :results silent #+HEADER: :tangle no #+BEGIN_SRC bash rm -rf /tmp/python \ && mkdir /tmp/python \ && cd /tmp/python \ && virtualenv venv \ && source venv/bin/activate \ && pip install flask #+END_SRC #+HEADER: :tangle /tmp/python/blog.py #+BEGIN_SRC python import flask app = flask.Flask(__name__) @app.route('/posts', methods = ['GET']) def get_posts(): return [ {'title': 'Title of post 1'}, {'title': 'Title of post 2'}, {'title': 'Title of post 3'} ], 200 @app.route('/categories', methods = ['GET']) def get_categories(): return [ {'name': 'Category 1'}, {'name': 'Category 2'}, {'name': 'Category 3'} ], 200 #+END_SRC #+HEADER: :tangle no #+BEGIN_SRC bash cd /tmp/python && source venv/bin/activate && python -m flask --app blog --debug run --port 4891 #+END_SRC ** System information Emacs version: GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2024-10-12 OS: Ubuntu 22.04.5 LTS Org mode version: 9.6.15 --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename="a.org" Content-Transfer-Encoding: 8bit #+HEADER: :tangle no #+HEADER: :results verbatim #+BEGIN_SRC sh curl --silent --request GET 'http://localhost:4891/posts' #+END_SRC #+RESULTS: #+begin_example [ { "title": "Title of post 1" }, { "title": "Title of post 2" }, { "title": "Title of post 3" } ] #+end_example #+HEADER: :tangle no #+HEADER: :results verbatim #+BEGIN_SRC sh curl --include --silent --request GET 'http://localhost:4891/posts' #+END_SRC #+RESULTS: #+begin_example HTTP/1.1 200 OK Server: Werkzeug/3.0.4 Python/3.10.12 Date: Thu, 17 Oct 2024 15:02:54 GMT Content-Type: application/json Content-Length: 123 Connection: close [ { "title": "Title of post 1" }, { "title": "Title of post 2" }, { "title": "Title of post 3" } ] #+end_example #+HEADER: :tangle no #+HEADER: :results verbatim #+BEGIN_SRC sh seq 1 10 #+END_SRC #+RESULTS: #+begin_example 1 2 3 4 5 6 7 8 9 10 #+end_example --=-=-=--