leading tabs in here-documents are always stripped even when they should not

Bug #1837202 reported by Detlev Zundel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Here documents from the command line with tabs are not handled correctly. Here is a transcript showing the problem - there is a tab in front of "This is indented" in the file:

dzu@zarniwoop:~$ cat tab-test
#!/bin/bash

cat <<STOP
This is unindented
 This is indented
STOP
dzu@zarniwoop:~$ bash tab-test
This is unindented
 This is indented
dzu@zarniwoop:~$ echo "Now using mouse to copy&paste here-document"
Now using mouse to copy&paste here-document
dzu@zarniwoop:~$ cat <<STOP
> This is unindented
> This is indented
> STOP
This is unindented
This is indented
dzu@zarniwoop:~$

Dash handles this correctly:

dzu@zarniwoop:~$ dash
$ dash tab-test
This is unindented
 This is indented
$ echo "Now using mouse to copy&paste here-document"
Now using mouse to copy&paste here-document
$ cat <<STOP
This is unindented
 This is indented
STOP
> > > This is unindented
 This is indented
$

The prompts in the dash output are suspicious but redirecting the output into a file yields correct output.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: bash 4.4.18-2ubuntu1.2
ProcVersionSignature: Ubuntu 4.18.0-25.26~18.04.1-generic 4.18.20
Uname: Linux 4.18.0-25-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.9-0ubuntu7.7
Architecture: amd64
CurrentDesktop: GNOME
Date: Fri Jul 19 11:45:27 2019
InstallationDate: Installed on 2019-05-28 (51 days ago)
InstallationMedia: Ubuntu 18.04.2 LTS "Bionic Beaver" - Release amd64 (20190210)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=de_DE.UTF-8
 SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Detlev Zundel (laodzu) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.