You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] mkdir -p f exits 0 with no error when f is an existing regular file #372
I have updated to the latest minor and patch version of Strands Shell (built from main @ dbb6189)
I have checked the documentation and this is not expected behavior
I have searched ./issues and there are no duplicates of my issue
Binding
Rust
Strands Shell Version
dbb6189 (--version prints 0.0.0)
Language Runtime Version
Rust 1.100.0
Operating System
Linux 6.18 (aarch64)
Installation Method
built from source
Steps to Reproduce
strands-shell -c 'echo x > f; mkdir -p f && echo made; echo "rc=$?"'
Expected Behavior
Same as coreutils 9.1: mkdir: cannot create directory 'f': File exists, nothing from echo made, and rc=1.
Actual Behavior
maderc=0
No error is printed and f is still a regular file, so a script that guards on mkdir -p out && ... carries on without the directory. The same happens when the operand is a symlink to a regular file (ln -s f l; mkdir -p l exits 0; coreutils exits 1), and on a direct bind.
Without -p it is correct: mkdir f prints strands-shell: mkdir: f: already exists and exits 1.
Additional Context
Found while reviewing #354, which moves this code into a helper without changing it. The result is the same on that PR's base dbb6189 and head 4946e4b.
Possible Solution
The -p walk skips the last component when it exists, without checking that it is a directory: io::stat(os, &path).await.exists at src/commands/mkdir.rs:53 on main. Skipping only when stat.is_dir, and otherwise letting create_dir report the existing file, should do it. I have not written or tested a fix.
Activity