Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux shell 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3 Patch Level: 48 Release Status: release Description: Multiline commands (i.e., a command with embedded newlines) do not survive intact when written out to the history file and then reloaded. Repeat-By: See attached script file: Recording to file 'typescript' at: Sun Jun 11 18:51:27 2017. ~s to stop recording, ~r to resume spawn bash gazelle@shell:~$ HISTFILE=/tmp/zzz gazelle@shell:~$ history -c;history -r;history gazelle@shell:~$ gawk 'BEGIN { > print "hello, world" > }' hello, world gazelle@shell:~$ history 1 gawk 'BEGIN { print "hello, world" }' 2 history gazelle@shell:~$ !1 gawk 'BEGIN { print "hello, world" }' hello, world gazelle@shell:~$ history -w gazelle@shell:~$ history -c;history -r;history 1 gawk 'BEGIN { 2 print "hello, world" 3 }' 4 history 5 gawk 'BEGIN { 6 print "hello, world" 7 }' 8 history -w gazelle@shell:~$ !5 gawk 'BEGIN { > ^C gazelle@shell:~$ exit Fix: I think there needs to be some kind of "magic character" in the history file that represents a newline - which would be handled by the -w and -r options of the history command.