Le jeu. 10 avr. 2025 à 18:29, Laurent Lyaudet <laurent.lyau...@gmail.com> a
écrit :

> Hello :),
>
> Recently, I noticed during tests that mkdir -p can handle paths beyond
> PATH_MAX that is currently 4096.
> But cd cannot do this.
> You have to split your cd commands to go to the farthest directory.
>
> I think that cd cannot move if it fails.
> In case of error, it must keep bash in the same current directory.
> Maybe I'm wrong.
>
> But if I'm wrong and that is not a requirement,
> then splitting the path before recursive calls of one level depth cd would
> make cd as resilient as mkdir -p.
> If I'm not wrong, we need to handle some kind of backtracking in cd.
> I hope this is something that can be done.
> I will not argue further if it's not accepted here.
>
> ***Below greetings is some sample script to demonstrate/reproduce the
> "bug/more resilient feature request"***
> (For reference, here is where this problem comes out:
>
> https://discourse.ubuntu.com/t/increasing-path-max-to-8092-and-name-max-to-512/58748/20?u=laurent-lyaudet
> )
>
> Best regards,
>     Laurent Lyaudet
>
> #!/bin/bash
>
> # base 16, each lines count for 64, 64*64=4096
> mkdir -p 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> another_too_long_string_to_certainly_be_over_4096
> echo ""
> echo ""
> echo "mkdir -p works above 4096"
> echo ""
> echo ""
> cd 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> another_too_long_string_to_certainly_be_over_4096 || (\
> echo "" &&\
> echo "" &&\
> echo "cd fails above 4096" &&\
> echo "" &&\
> echo "")
> cd 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/
> echo ""
> echo ""
> echo "1) split cd works for 2048"
> echo ""
> echo ""
> cd 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/\
> 0123456789012345/0123456789012345/0123456789012345/0123456789012345/
> echo ""
> echo ""
> echo "2) split cd works for 2048"
> echo ""
> echo ""
> cd another_too_long_string_to_certainly_be_over_4096
> echo ""
> echo ""
> echo "3) split cd works for the last directory above 4096"
> echo ""
> echo ""
>
>
>
Sorry, I forgot to say that I already know there is also another upper
limit to a command line length.
But it is less relevant to this problem.

Reply via email to