Hi,
I am using “dialog” for displaying forms where the users input text. The box calls for name, street, city and phone number which should later be divided for processing. Using Debian all runs fine. Default separator is TAB and I can split the output using “cut” command. But the same script under Arch uses SPACE as the default separator which causes issues because of the input text can contain spaces. So I tried the option --output-separator “\t”. It results in an separation of the ASCII for \ followed by the ASCII of t. If I use a single character it works as expected, but if I try to use CR, LF or TAB I am unable to get these separators running Arch. Using Debian it works. I am totally confused now. Is it a bug? Or has dialog changed and the changings have not reached Debian yet?
Well, there is a version difference.
Debian (main).
I think this version is realeased in 2020-11-26
Debian (testing).
Arch (official repo)
x86_64 Core dialog 1:1.3_20210621-1 A tool to display dialog boxes from shell scripts 2021-06-27
Version used in Arch core is still under sid
in Debian.
Does this work:
--output-separator "$'\t'"
Other chars you mentioned:
$'\r' # CR
$'\n' # LF
Using Arch:
–output-delimiter “\t” results in ASCII \ and ASCII t
–output-delimiter ‘\t’ results in ASCII \ and ASCII t
–output-delimiter $’\t’ results in SPACE (0x20)
–output-delimiter “$’\t’” results in ASCII $ and ASCII ’ and ASCII \ and ASCII t and ASCII ’
–output-delimiter ‘\r’ results in ASCII \ and ASCII r
–output-delimiter $’\r’ results in CR
–output-delimiter $’\n’ results in SPACE
It is absolutely confusing.
Yes. It results in ASCII $ and ASCII ’ and ASCII \ and ASCII t and ASCII ’
There seems to be more differences I tried to use another seperator than TAB. I want to use TAB because of I split the result using cut and cut has default delimiter TAB. When I want to use e.g. CR as delimiter this cannot be implied to Debian and Arch cut same way. Using syntax 1 results in Arch working and Debian telling "delimiter must be single character and using syntax 2 works in Debian and Arch complaining… Sadly the script has to run under Debian AND Arch…
I have done more investigations. What I never mentioned was the shell I use. The script uses /bin/sh and gives the reported behaviour. Now I switch to /bin/bash and use $’\r’ as delimiter both for dialog and cut and it is accepted by Debian and Arch!!! The ecript has already run on both systems for years using /bin/sh and TAB as a delimiter. I have not used it for a longer time and now it has shown the strange behaviour. I cannot tell when this popped up - it can be months ago. Nut using bash it runs with switching to CR as delimiter…
Debian uses Dash as /bin/sh
while Arch uses Bash as /bin/sh
Try adding
set -o posix
before the dialog
command. Use #!/bin/bash
for this (do not use #!/bin/sh
for this, as this is a bashism).
You can set and unset this option if you need bashisms in your script:
set -o posix
# execute your dialog command here
set +o posix
# you can run bashisms again here
Bingo.
I have found the solution by try&error - you gave me the explanation for this behaviour. I love Endeavour Community! Many thanks to all for the hints.
Also relevant:
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.