mrr <
mir...@free.fr> writes:
> Ok, I guess most of you know Yakuake! As far as I can see it works
> like a charm in fluxbox (as does Guake and Tilda).
>
> My issue is with i3, when I execute it, it fails loading completely
> with an error like:
I’ve never heard of any of the above things, so I may be missing some
context in what follows.
> "/bin/cd" not found
> And until I kill it, it takes 100% of one processor.
>
> cd is a shell builtin (at least on my debian) so it's no surprise that
> it can't find it in the bin directory.
> What I'd like, just for testing purpose (and now for the challenge
> too), would be to implement my /bin/cd in a shell script maybe using
> the cd builtin.
> The naive approach (I often begin like that actually!) is to simply
> call cd as in:
>
> #!/bin/bash
> cd "$@"
>
> But as the shell forks it actually changes only the son's working directory.
> Question:
> - Is there a simple (or not) way to do it via a script?
> - If not (and here we're getting out of Linux theme, feel free to
> ignore this if you want), any hint at how to do it in C?
1. A process trying to change its own directory by running /bin/cd will
never work. This is just broken. The answer is to fix the broken
program (or possibly its configuration, if it’s just blindly
executing stuff found there).
2. SUS does require that cd be accessible via execve(). See s1.6 of
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html
i.e. the absence of /bin/cd (or /usr/bin/cd or similar) on most Linux
systems is a standards violation, albeit not a very interesting one.
3. SUS also acknowledges that accessing cd via execve() will not
actually change a caller’s working directory. See ‘Application
usage’ in
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html
- as such the executable version (if it exists) is only really usable
for testing whether something is an accessible directory.
4. The only way to make a /bin/cd that actually changed its parent’s
directory would for it to use a debugger (or the underlying ptrace
syscall) to attach to its parent and run chdir() inside it. This
doesn’t seem like a very good idea since anything that relies on a
standards-conforming /bin/cd will stop working properly. It also
won’t work on all processes.
--
http://www.greenend.org.uk/rjk/