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

eepflash.sh fails with ~ in eeprom filename #76

Open
beikeland opened this issue Dec 6, 2020 · 2 comments
Open

eepflash.sh fails with ~ in eeprom filename #76

beikeland opened this issue Dec 6, 2020 · 2 comments

Comments

@beikeland
Copy link

not quite sure if its a real problem, but using ~ is a convenient short hand at least.

doesn't work

pi@raspberrypi:~ $ sudo ~/hats/eepromutils/eepflash.sh -w -t=24c32 -d=0 -a=50 \
>     -f=~/hats/eepromutils/eeprom.cs0.irq0.bin
This will attempt to talk to an eeprom at i2c address 0x50 on bus 0. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
dd: failed to open '~/hats/eepromutils/eeprom.cs0.irq0.bin': No such file or directory
Closing EEPROM Device.
Error doing I/O operation.

does work

pi@raspberrypi:~ $ sudo ~/hats/eepromutils/eepflash.sh -w -t=24c32 -d=0 -a=50 \
>     -f=/home/pi/hats/eepromutils/eeprom.cs0.irq0.bin
This will attempt to talk to an eeprom at i2c address 0x50 on bus 0. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
1024 bytes (1.0 kB, 1.0 KiB) copied, 4 s, 0.3 kB/s
2+1 records in
2+1 records out
1403 bytes (1.4 kB, 1.4 KiB) copied, 5.39316 s, 0.3 kB/s
Closing EEPROM Device.
Done.
@mhei
Copy link
Contributor

mhei commented Jun 2, 2021

I think this is expected behavior and not a bug: since you pass the parameters to sudo, the script then runs as user root and it tries to locate the eeprom.cs0.irq0.bin in the root user's home directory and referenced path. I don't see how this could be prevented.

pelwell added a commit that referenced this issue Jun 22, 2021
Shell expansion of ~ to $HOME (e.g. ~/filename), and TAB completion
on the command line, doesn't work in the middle of a string. Accept
-f filename and --file filename in addition to the usual -f=filename
and --file=filename as a way around this problem.

See: #76

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell
Copy link
Contributor

pelwell commented Jun 22, 2021

Having rediscovered this issue I've added support for passing the file name as a separate parameter, e.g.
./eepflash.sh -f ~/my_hat.eep .... This allows shell expansion (and TAB completion) to work on it.

aentinger pushed a commit to pika-spark/portenta-x8-eeprom-utils that referenced this issue Aug 3, 2023
Shell expansion of ~ to $HOME (e.g. ~/filename), and TAB completion
on the command line, doesn't work in the middle of a string. Accept
-f filename and --file filename in addition to the usual -f=filename
and --file=filename as a way around this problem.

See: raspberrypi/hats#76

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
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

3 participants