From: Osher Jacob <osherz5@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)]
Date: Mon, 16 Jan 2023 18:27:52 +0200 [thread overview]
Message-ID: <CAGsxwFZ88cybALCVGgma=5gENMhUa0Rk6xNkBNS_HdsmBgYe6w@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 11129 bytes --]
*Expected behaviour:*On Windows, all lines of the babel shell block should
be evaluated, with full output printed.
*Actual behaviour:*All lines but the last are evaluated, the output ends
with 'More?'
instead of the last command's output.
*Steps to reproduce:*In Windows, start a clean Emacs instance (I used
"runemacs.exe -Q"), and evaluate the following blocks:
1) Enable shell language support
#+begin_src elisp
(org-babel-do-load-languages
'org-babel-load-languages
'(
(shell . t)
)
)
#+end_src
#+RESULTS:
2) Evaluate this shell code block
#+begin_src shell
echo 1
echo 2
#+end_src
#+RESULTS:
| Microsoft | Windows | [Version | 10.0.19044.2364] |
| |
| (c) | Microsoft | Corporation. | All |
rights | reserved. |
| | | | |
| |
| c:\Users\osherj>echo | 1 | | |
| |
| 1 | | | |
| |
| | | | |
| |
| c:\Users\osherj>More? | | | |
| |
*Additional info:*After some debugging, it seems to be caused by a missing
newline character at the
end of the code block content.
I believe this is caused by the org-trim function which is called upon the
body of the block.
At the function:
org/ob-shell.el -> (defun org-babel-sh-evaluate ...)
The line:
(org-babel-eval shell-file-name (org-trim body))
*Suggested fix:*The hacky way I solved it was to change this line:
(t (org-babel-eval shell-file-name (org-trim body))))))
to this:
(t (org-babel-eval shell-file-name (concat (org-trim body) "\n"))))))
Also attached as a patch file
Let me know if there's any other information you need, or if I can help in
any other way.
Thanks!
Osher
Emacs : GNU Emacs 28.2 (build 2, x86_64-w64-mingw32)
of 2022-09-13
Package: Org mode version 9.6.1 ( @
c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)
current state:
==============
(setq
org-link-elisp-confirm-function 'yes-or-no-p
org-format-latex-header
"\\documentclass{article}\n\\usepackage[usenames]{color}\n[PACKAGES]\n[DEFAULT-PACKAGES]\n\\pagestyle{empty}
% do not remove\n% The settings below are copied from
fullpage.sty\n\\setlength{\\textwidth}{\\paperwidth}\n\\addtolength{\\textwidth}{-3cm}\n\\setlength{\\oddsidemargin}{1.5cm}\n\\addtolength{\\oddsidemargin}{-2.54cm}\n\\setlength{\\evensidemargin}{\\oddsidemargin}\n\\setlength{\\textheight}{\\paperheight}\n\\addtolength{\\textheight}{-\\headheight}\n\\addtolength{\\textheight}{-\\headsep}\n\\addtolength{\\textheight}{-\\footskip}\n\\addtolength{\\textheight}{-3cm}\n\\setlength{\\topmargin}{1.5cm}\n\\addtolength{\\topmargin}{-2.54cm}"
org-bibtex-headline-format-function '(closure (org-id-locations
org-agenda-search-view-always-boolean org-agenda-overriding-header t)
(entry)
(cdr (assq :title entry)))
org-persist-after-read-hook '(org-element--cache-persist-after-read)
org-time-stamp-custom-formats '("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>")
org-export-before-parsing-hook '(org-attach-expand-links)
org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
org-archive-hook '(org-attach-archive-delete-maybe)
org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
org-ascii-format-drawer-function '(closure (t) (_name contents _width)
contents)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
org-cycle-show-empty-lines org-optimize-window-after-visibility-change)
org-persist-before-read-hook '(org-element--cache-persist-before-read)
org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook
change-major-mode-hook org-fold-show-all append local] 5]
(closure
(org--rds reftex-docstruct-symbol org--single-lines-list-is-paragraph
visual-fill-column-width org-clock-history
org-agenda-current-date org-with-time org-defdecode org-def
org-read-date-inactive org-ans2 org-ans1 org-columns-current-fmt-compiled
org-clock-current-task org-clock-effort org-agenda-skip-function
org-agenda-skip-comment-trees org-agenda-archives-mode
org-end-time-was-given org-time-was-given org-blocked-by-checkboxes
org-state org-agenda-headline-snapshot-before-repeat
org-agenda-buffer-name org-agenda-start-on-weekday
org-agenda-buffer-tmp-name buffer-face-mode-face org-struct-menu
org-last-state
org-clock-start-time texmathp-why remember-data-file
org-agenda-tags-todo-honor-ignore-options calc-embedded-open-mode
calc-embedded-open-formula calc-embedded-close-formula
align-mode-rules-list org-export-registered-backends crm-separator
org-id-overriding-file-name org-indent-indentation-per-level
org-element--timestamp-regexp org-element-cache-map-continue-from
org-element-paragraph-separate org-agenda-buffer-name
org-inlinetask-min-level t)
nil (add-hook 'change-major-mode-hook 'org-fold-show-all 'append 'local))
(closure (*this* org-babel-confirm-evaluate-answer-no t) nil
(add-hook 'change-major-mode-hook #'org-babel-show-result-all 'append
'local))
#[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)
org-babel-load-languages '((shell . t))
org-latex-format-drawer-function '(closure (engrave-faces-latex-mathescape
engrave-faces-current-preset-style engrave-faces-latex-output-style t)
(_ contents) contents)
org-latex-format-headline-function
'org-latex-format-headline-default-function
org-confirm-shell-link-function 'yes-or-no-p
org-html-format-drawer-function '(closure
(htmlize-buffer-places org-html-format-table-no-css
htmlize-css-name-prefix htmlize-output-type htmlize-output-type
htmlize-css-name-prefix t)
(_name contents) contents)
outline-isearch-open-invisible-function 'outline-isearch-open-invisible
org-fold-catch-invisible-edits nil
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
org-confirm-elisp-link-function 'yes-or-no-p
org-preview-latex-process-alist '((dvipng :programs ("latex" "dvipng")
:description "dvi > png" :message
"you need to install the programs: latex and dvipng." :image-input-type
"dvi" :image-output-type "png"
:image-size-adjust (1.0 . 1.0) :latex-compiler ("latex -interaction
nonstopmode -output-directory %o %f")
:image-converter ("dvipng -D %D -T tight -bg Transparent -o %O %f"))
(dvisvgm :programs ("latex" "dvisvgm") :description "dvi > svg" :message
"you need to install the programs: latex and dvisvgm." :image-input-type
"dvi" :image-output-type "svg"
:image-size-adjust (1.7 . 1.5) :latex-compiler ("latex -interaction
nonstopmode -output-directory %o %f")
:image-converter ("dvisvgm %f -n -b min -c %S -o %O"))
(imagemagick :programs ("latex" "convert") :description "pdf > png"
:message
"you need to install the programs: latex and imagemagick."
:image-input-type "pdf" :image-output-type "png"
:image-size-adjust (1.0 . 1.0) :latex-compiler ("pdflatex -interaction
nonstopmode -output-directory %o %f")
:image-converter ("convert -density %D -trim -antialias %f -quality 100
%O"))
)
org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-odt-format-drawer-function '(closure
(hfy-user-sheet-assoc hfy-html-quote-regex hfy-html-quote-map
hfy-face-to-css hfy-begin-span-handler
hfy-end-span-handler nxml-auto-insert-xml-declaration-flag t)
(_name contents) contents)
org-persist-directory
"c:/Users/Osher/AppData/Local/Temp/org-persist-bvcjPn"
org-babel-exp-code-template "#+BEGIN_SRC
%lang%switches%flags\n%body\n#+END_SRC"
org-fold-core-isearch-open-function 'org-fold--isearch-reveal
org-latex-format-inlinetask-function
'org-latex-format-inlinetask-default-function
org-persist-before-write-hook '(org-element--cache-persist-before-write)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
org-link-shell-confirm-function 'yes-or-no-p
org-babel-pre-tangle-hook '(save-buffer)
org-agenda-loop-over-headlines-in-active-region nil
org-occur-hook '(org-first-headline-recenter)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-link-parameters '(("attachment" :follow org-attach-follow :complete
org-attach-complete-link) ("id" :follow org-id-open)
("eww" :follow org-eww-open :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 :insert-description
org-info-description-as-command)
("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) ("doi" :follow org-link-doi-open
:export org-link-doi-export) ("file+sys") ("file+emacs")
("shell" :follow org-link--open-shell)
("news" :follow #[514 "\301\300\302 Q \"\207" ["news" browse-url ":"]
6 "\n\n(fn URL ARG)"])
("mailto" :follow #[514 "\301\300\302 Q \"\207" ["mailto" browse-url
":"] 6 "\n\n(fn URL ARG)"])
("https" :follow #[514 "\301\300\302 Q \"\207" ["https" browse-url
":"] 6 "\n\n(fn URL ARG)"])
("http" :follow #[514 "\301\300\302 Q \"\207" ["http" browse-url ":"]
6 "\n\n(fn URL ARG)"])
("ftp" :follow #[514 "\301\300\302 Q \"\207" ["ftp" browse-url ":"] 6
"\n\n(fn URL ARG)"])
("help" :follow org-link--open-help :store org-link--store-help)
("file" :complete org-link-complete-file)
("elisp" :follow org-link--open-elisp))
org-html-format-headline-function
'org-html-format-headline-default-function
org-metaup-hook '(org-babel-load-in-session-maybe)
org-src-lang-modes '(("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))
)
[-- Attachment #1.2: Type: text/html, Size: 13284 bytes --]
[-- Attachment #2: ob-shell-eval-with-newline --]
[-- Type: application/octet-stream, Size: 584 bytes --]
diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 2c30a2605..95ea4f635 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -324,7 +324,7 @@ return the value of the last statement in BODY."
(insert body))
(set-file-modes script-file #o755)
(org-babel-eval script-file "")))
- (t (org-babel-eval shell-file-name (org-trim body))))))
+ (t (org-babel-eval shell-file-name (concat (org-trim body) "\n"))))))
(when (and results value-is-exit-status)
(setq results (car (reverse (split-string results "\n" t)))))
(when results
next reply other threads:[~2023-01-16 18:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 16:27 Osher Jacob [this message]
2023-01-16 21:40 ` [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)] Matt
2023-01-17 1:07 ` Matt
2023-01-17 19:53 ` Osher Jacob
2023-01-18 5:09 ` Matt
2023-01-18 9:05 ` Ihor Radchenko
2023-01-19 16:28 ` Osher Jacob
2023-01-20 4:29 ` Matt
2023-01-20 9:27 ` Ihor Radchenko
2023-01-23 3:12 ` Matt
2023-01-23 11:42 ` Ihor Radchenko
2023-01-26 4:04 ` Matt
2023-01-26 9:51 ` Ihor Radchenko
2023-01-30 6:00 ` Matt
2023-01-30 14:00 ` Ihor Radchenko
2023-01-30 17:08 ` Matt
2023-02-01 12:05 ` Ihor Radchenko
2023-02-01 20:21 ` Matt
2023-01-20 9:24 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGsxwFZ88cybALCVGgma=5gENMhUa0Rk6xNkBNS_HdsmBgYe6w@mail.gmail.com' \
--to=osherz5@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).