Skip to content

Echo command in Dockerfile used to write aliases missing -e flag? #361

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

Open
NickCheng0921 opened this issue Feb 2, 2025 · 1 comment
Open

Comments

@NickCheng0921
Copy link

As of 2/2/25
In the Dockerfile for openworm,

RUN echo '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"' >> ~/.bashrc
doesn't seem to update bashrc properly

Running source ~/.bashrc throws the below error
root@1a2cf2d71234:/# source ~/.bashrc
bash: nnalias: command not found

As the aliases aren't written into the bashrc correctly

Instead, using -e interprets the string properly
RUN echo '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"' >> ~/.bashrc

~/.bashrc with -e
alias cd..='cd ..'
alias h='history'
alias ll='ls -alt'

~/.bashrc without -e
\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"

@pgleeson
Copy link
Member

pgleeson commented Feb 7, 2025

Thanks for pointing this out @NickCheng0921. It seems versions of echo on different systems have different options, some support -e, others only support -n.

The base image used here is ubuntu 22.04, and this doesn't require the -e. To get round this all, I've changed the Dockerfile to use printf:

RUN printf '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"\n' >> ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants