Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning when running scp over openssh-server #1

Merged
merged 1 commit into from
May 6, 2015

Conversation

tdaitx
Copy link
Contributor

@tdaitx tdaitx commented May 5, 2015

When running scp to copy a file to dietpi I saw the following problem:

$ scp file root@dietpi
/boot/dietpi/login: line 41: [: too many arguments

Adding more debug information:

$ scp file root@dietpi
++ sed -n 1p /boot/dietpi/.hw_model
+ HW_MODEL=1
++ sed -n 2p /boot/dietpi/.hw_model
+ HW_MODEL_DESCRIPTION='Raspberry Pi 1 (512MB)'
++ sed -n 3p /boot/dietpi/.hw_model
+ DISTRO=1
++ cat /boot/dietpi/.install_stage
+ DIETPI_INSTALL_STAGE=1
++ cat /boot/dietpi/.auto_boot_index
+ AUTO_BOOT_INDEX=0
++ cat /boot/dietpi/.version
+ DIETPI_VERSION=51
+ ((  1 == 1  ))
+ '[' -z '' ']'
++ tty
+ '[' not a tty == /dev/tty1 ']'
/boot/dietpi/login: line 41: [: too many arguments
+ /boot/dietpi/dietpi-banner 1

The safe way to go is to use $(tty) inside double quotes.

Note: I'm using the openssh-server package, I haven't tested it with dropbear.

When running scp over openssh-server in dietpi I saw the following problem:
/boot/dietpi/login: line 41: [: too many arguments

Adding more debug information:
++ sed -n 1p /boot/dietpi/.hw_model
+ HW_MODEL=1
++ sed -n 2p /boot/dietpi/.hw_model
+ HW_MODEL_DESCRIPTION='Raspberry Pi 1 (512MB)'
++ sed -n 3p /boot/dietpi/.hw_model
+ DISTRO=1
++ cat /boot/dietpi/.install_stage
+ DIETPI_INSTALL_STAGE=1
++ cat /boot/dietpi/.auto_boot_index
+ AUTO_BOOT_INDEX=0
++ cat /boot/dietpi/.version
+ DIETPI_VERSION=51
+ ((  1 == 1  ))
+ '[' -z '' ']'
++ tty
+ '[' not a tty == /dev/tty1 ']'
/boot/dietpi/login: line 41: [: too many arguments
+ /boot/dietpi/dietpi-banner 1

The safe way to go is to use $(tty) inside double quotes.
@Fourdee
Copy link
Collaborator

Fourdee commented May 6, 2015

Hi tdaitx,

Great find, appreciate the fix 👍

This will also be released in a few days with DietPi _v52.img.

Fourdee added a commit that referenced this pull request May 6, 2015
Fix warning when running scp over openssh-server
@Fourdee Fourdee merged commit 52cb572 into MichaIng:master May 6, 2015
@@ -38,7 +38,7 @@
if (( $DIETPI_INSTALL_STAGE == 1 )); then

#Boot to specific Program
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
if [ -z "$DISPLAY" ] && [ "$(tty)" == /dev/tty1 ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll also remove the double parentheses (c style ==) as this is not arithmetic, and, set to double quotes on both input and output values.

if [ "$(tty)" = "/dev/tty1" ]; then

@pidiet pidiet mentioned this pull request Aug 9, 2017
This was referenced Aug 19, 2017
@Snoevit Snoevit mentioned this pull request Sep 2, 2017
@qpens qpens mentioned this pull request Sep 22, 2017
@gioxx gioxx mentioned this pull request Feb 19, 2024
1 task
@cserl cserl mentioned this pull request Mar 1, 2024
1 task
@isarrider isarrider mentioned this pull request May 23, 2024
@shlatchz shlatchz mentioned this pull request Oct 12, 2024
1 task
@NatureHog NatureHog mentioned this pull request Oct 28, 2024
1 task
@way5 way5 mentioned this pull request Nov 30, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants