From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Re: Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)] Date: Tue, 11 Feb 2020 13:15:51 -0700 Message-ID: References: <17855F72-DCCD-48B3-BEF0-056A1267C270@squelch.io> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:60689) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1bws-0006fY-Dv for emacs-orgmode@gnu.org; Tue, 11 Feb 2020 15:16:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1bwq-0005Sa-NM for emacs-orgmode@gnu.org; Tue, 11 Feb 2020 15:15:58 -0500 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:33846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j1bwq-0005OH-Ds for emacs-orgmode@gnu.org; Tue, 11 Feb 2020 15:15:56 -0500 Received: by mail-lf1-x12d.google.com with SMTP id l18so7975993lfc.1 for ; Tue, 11 Feb 2020 12:15:53 -0800 (PST) In-Reply-To: <17855F72-DCCD-48B3-BEF0-056A1267C270@squelch.io> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Max Flander Cc: "emacs-orgmode@gnu.org" you probably already tried this to judge from your links but it's worth poinitng out for mailing list readers that shell blocks use the exit code. a user who just wants to run a diff or grep for the stdio results (stderr and stdout) has to stop that mechanism. if you want both stdin and stout, you need to combine them. note that stderr is normally unbuffered, so the sequence might or might not be preserved. and if you want to stop babel from thinking it should do something different with nonzero ec, you have to stop that. all of this i think needs to be done in shell code inside the block. On 10/29/19, Max Flander wrote: > I'm trying to capture the output of rg but I'm getting no output (I'm > getting the message "Code block produced no output" in the minibuffer. > > I've also tried ag and pt which don't work either. It works with grep but > this is too slow for my use-case. > > Example: > > #+BEGIN_SRC shell > mkdir -p myproject > pushd myproject > echo "something" > something.txt > rg something > popd > #+END_SRC > > #+RESULTS: > > I've tried the solutions from these similar questions, but they're not > working here: > > * > https://stackoverflow.com/questions/27304469/capturing-the-output-of-diff-with-org-babel > * > https://stackoverflow.com/questions/12771642/capture-output-from-a-shell-command-with-babel-in-org-mode?noredirect=1&lq=1 > > Emacs : GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.5.0, NS > appkit-1671.40 Version 10.14.4 (Build 18E226)) > of 2019-08-30 > Package: Org mode version 9.2.6 (9.2.6-4-ge30905-elpaplus @ > /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/) > > current state: > ============== > (setq > org-src-mode-hook '(org-src-babel-configure-edit-buffer > org-src-mode-configure-edit-buffer) > org-metadown-hook '(org-babel-pop-to-session-maybe) > org-clock-out-hook '(org-clock-remove-empty-clock-drawer) > org-html-format-inlinetask-function > 'org-html-format-inlinetask-default-function > org-odt-format-headline-function 'org-odt-format-headline-default-function > org-imenu-depth 8 > org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default > org-mode-hook '(org-indent-mode #[0 "\301\211\207" > [imenu-create-index-function org-imenu-get-tree] 2] > #[0 "\300\301\302\303\304$\207" [add-hook > change-major-mode-hook org-show-all append local] 5] > #[0 "\300\301\302\303\304$\207" > [add-hook change-major-mode-hook > org-babel-show-result-all append local] 5] > org-babel-result-hide-spec org-babel-hide-all-hashes > toc-org-enable org-bullets-mode > org-eldoc-load) > org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"] > org-archive-hook '(org-attach-archive-delete-maybe) > org-confirm-elisp-link-function 'yes-or-no-p > org-startup-with-inline-images t > org-agenda-before-write-hook '(org-agenda-add-entry-text) > org-metaup-hook '(org-babel-load-in-session-maybe) > org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 > "\n\n(fn ENTRY)"] > org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"] > org-babel-pre-tangle-hook '(save-buffer) > org-tab-first-hook '(org-babel-hide-result-toggle-maybe > org-babel-header-arg-expand) > org-babel-load-languages '((shell . t)) > org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS > WIDTH)"] > org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php) > ("C" . c) ("C++" . c++) > ("asymptote" . asy) ("bash" . sh) ("beamer" . latex) > ("calc" . fundamental) ("cpp" . c++) > ("ditaa" . artist) ("dot" . fundamental) ("elisp" . > emacs-lisp) ("ocaml" . tuareg) > ("screen" . shell-script) ("shell" . sh) ("sqlite" . > sql)) > org-occur-hook '(org-first-headline-recenter) > org-cycle-hook '(org-cycle-hide-archived-subtrees > org-cycle-show-empty-lines > org-optimize-window-after-visibility-change) > org-speed-command-hook '(org-speed-command-activate > org-babel-speed-command-activate) > org-odt-format-inlinetask-function > 'org-odt-format-inlinetask-default-function > org-confirm-shell-link-function 'yes-or-no-p > org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww :store > org-eww-store-link) > ("rmail" :follow org-rmail-open :store > org-rmail-store-link) > ("mhe" :follow org-mhe-open :store > org-mhe-store-link) > ("irc" :follow org-irc-visit :store > org-irc-store-link :export org-irc-export) > ("info" :follow org-info-open :export org-info-export > :store org-info-store-link) > ("gnus" :follow org-gnus-open :store > org-gnus-store-link) > ("docview" :follow org-docview-open :export > org-docview-export :store org-docview-store-link) > ("bibtex" :follow org-bibtex-open :store > org-bibtex-store-link) > ("bbdb" :follow org-bbdb-open :export org-bbdb-export > :complete org-bbdb-complete-link > :store org-bbdb-store-link) > ("w3m" :store org-w3m-store-link) ("file+sys") > ("file+emacs") > ("orgit-rev" :store orgit-rev-store :follow > orgit-rev-open :export orgit-rev-export > :complete orgit-rev-complete-link) > ("orgit-log" :store orgit-log-store :follow > orgit-log-open :export orgit-log-export > :complete orgit-log-complete-link) > ("orgit" :store orgit-status-store :follow > orgit-status-open :export orgit-status-export > :complete orgit-status-complete-link) > ("doi" :follow org--open-doi-link) ("elisp" :follow > org--open-elisp-link) > ("file" :complete org-file-complete-link) > ("ftp" :follow (lambda (path) (browse-url (concat > "ftp:" path)))) > ("help" :follow org--open-help-link) > ("http" :follow (lambda (path) (browse-url (concat > "http:" path)))) > ("https" :follow (lambda (path) (browse-url (concat > "https:" path)))) > ("mailto" :follow (lambda (path) (browse-url (concat > "mailto:" path)))) > ("news" :follow (lambda (path) (browse-url (concat > "news:" path)))) > ("shell" :follow org--open-shell-link)) > org-latex-format-headline-function > 'org-latex-format-headline-default-function > org-link-translation-function 'toc-org-unhrefify > org-latex-format-inlinetask-function > 'org-latex-format-inlinetask-default-function > org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"] > org-image-actual-width 400 > org-html-format-headline-function > 'org-html-format-headline-default-function > ) > > -- The Kafka Pandemic What is misopathy? https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html