[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
maybe a bug in bash?
From: |
Sebastian Luhnburg |
Subject: |
maybe a bug in bash? |
Date: |
Thu, 29 Jun 2023 11:55:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
Hello,
I'm sending this mail a past minutes ago, but I was not a member of this
mailing list. The mail was not listed in the archive, so I send it
again, with membership of the mailing list. I hope I don't sending it
twice to you.
I'm not sure, if I found a bug or if I miss some understanding, but I
want to report it, if it is a bug. Please tell me more, if I'm right or
if it is my mistake.
I have a script, in which I have an password (I get it from a password
manager - no excitement ;D ). The password begin with a $ and have an &
in middle. I want to use this password in an here document, which inject
some commands into a SSH-Connection (for simplification, I use the bash
instead of ssh in the test script below). To use the password in the
here document, I need to escape the special character. For this, I use
printf. The echo command in the here document give me the right output.
But if I run a subshell in the here document, the first \ for the $ is
being cut away. But why? At the moment I think this is a bug. But if it
is no bug, can you tell me why bash do this? My bash version is:
5.1.16(1)-release (x86_64-pc-linux-gnu) via Ubuntu 22.04.2 LTS.
You find a test script here:
#!/usr/bin/env bash
initial_password="\$abc&xyz"
echo "initial password: " $initial_password
printf -v password '%q' $initial_password
echo "initial password with escaped characters: " $password
bash << EOF
echo "password in here document: " ${password@Q}
/bin/bash -c "echo 'password in subshell in here document: ' ${password@Q}"
EOF
The output:
initial password: $abc&xyz
initial password with escaped characters: \$abc\&xyz
password in here document: \$abc\&xyz
password in subshell in here document: $abc\&xyz
Thank you very much!
Mit freundlichen Grüßen Sebastian Luhnburg IT
----------------------------------------------------------------------
swp software systems GmbH & Co. KG Königsbrücker Straße 124 01099
Dresden Tel: 0351-492850 Fax: 0351-4928550 www: https://www.vi-bim.de
Kennen Sie schon unsere FAQ-Wissensdatenbank? Einfach hier klicken:
https://faq.vi-bim.de Unsere Datenschutzerklärung finden Sie unter
https://datenschutz.vi-bim.de Registergericht: Amtsgericht Dresden HRA
3008 persönlich haftender Gesellschafter: swp Beteiligungs GmbH
Registergericht: Amtsgericht Dresden HRB 15 20 9 Geschäftsführer: Holger
Schönemann, Stefan Urlberger
OpenPGP_0x1E7D455B730DAD17.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
- maybe a bug in bash?,
Sebastian Luhnburg <=
Re: maybe a bug in bash?, Kerin Millar, 2023/06/29