Unexpected shell behavior?

A forum for general AmigaOS 4.x support questions that are not platform-specific
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Unexpected shell behavior?

Post by LyleHaze »

I noticed something lately that has me puzzled.
_maybe_ it has always been this way, but I don't think so.

I am in a shell, 4.1FE, and inside a directory is a shell command. the directory name and the command name are the same.

Example

>cd
FE:Utilities
>Filer

Now, does the shell CD to the Filer directory, or does it run Filer/Filer?

My first try, it CD'ed to Sys:Utilities/Filer
typing "Filer" again ran the program

Then I cd'ed back to Sys:Utilities,
types "Filer", and Filer ran!

So, typing the name of a directory might CD to that directory, and might run the (same named) executable within that directory, without ever CDing there.

Since I usually keep my projects in drawers of the same name, I probably would have noticed this long ago if it was classic behaviour.

Any thoughts?
User avatar
Raziel
Posts: 1170
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: Unexpected shell behavior?

Post by Raziel »

Have you thought about the "path" feature?

type "which Filer" in your shell and if a full path to the executable comes up it's known in path and will start filer from whereever you are in a shell

e.g. i'm in "SYS:" in a shell
my "Filer" sits on another partition (Tools:Utilities/Filer/Filer) and the "which" command shows just that
Typing "Filer" now starts the program
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Unexpected shell behavior?

Post by LyleHaze »

Does the path change without any command or request to change?
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Unexpected shell behavior?

Post by salass00 »

Just type the command "path" and you will get a list of the directories that are searched for commands. Most likely APPDIR: is one of them and if so that is what is causing the behaviour.
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Unexpected shell behavior?

Post by LyleHaze »

APPDIR: is part of my path.
I suppose I just don't understand how it works.

Sometimes I am just too old to figure out how this works. :roll:

Ah well. thanks all for the help anyway.
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Unexpected shell behavior?

Post by nbache »

LyleHaze wrote:APPDIR: is part of my path.
I suppose I just don't understand how it works.
In short, APPDIR: contains a lot of links, each pointing to the path from which each command was last executed.

So as soon as you have executed Filer once, there will be a link saved in APPDIR: with the name "Filer" and pointing to the path you used Filer from last. The next invocation of Filer will find a match in APPDIR:, and running it will actually run the program from the path saved before (the target of the link).

For most people, it's a help to never have to use an explicit path (other than the first time) to run a command.

For some of us, it can be a mixed blessing, e.g. if you have to test different versions of the same program, then you have to make sure always to start them with explicit paths, even if you have one of them in your path (e.g. in your current dir).

Best regards,

Niels
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Unexpected shell behavior?

Post by LyleHaze »

Thank You Sir.
That makes sense.

:)
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Unexpected shell behavior?

Post by xenic »

nbache wrote:For some of us, it can be a mixed blessing, e.g. if you have to test different versions of the same program, then you have to make sure always to start them with explicit paths, even if you have one of them in your path (e.g. in your current dir).
It's actually a pain in the a** if you're using the SDK and AmiCygnix. There are same named commands in AmiCygnix:bin, SDK:local/C and system C: directories. I had to rename the AppDir directory in ENVARC: and create a file named AppDir in ENVARC: to disable AppDir: altogether.

AppDir may have seemed to be a good idea (and may be for some users) but it's pain for others. It would be nice to have some prefs where you could disable some commands or programs from being added to Appdir and the addition of a "noappdir" command to the system C directory.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Unexpected shell behavior?

Post by LyleHaze »

I can understand how it could be very helpful to those users that spend most of their time playing with their mouse.
The CLI/Shell/Command Line can be very intimidating, requiring you to type in specific words in a very specific format to achieve success, and complaining in terms that are not understood if you fail to do so.

Making the "Path" almost automatic is a neat trick. I say almost because you have to get it right once.

But for luddites like myself who live in a shell, it presented a very confusing riddle. And that was aggrivated by my lack of understanding.
Because I was just OUTSIDE the named directory, I expect typing the name of the directory to "cd" me in. Sometimes it did, some times it did not.

Overlapping shortcuts:

Typing CD is optional when typing in a new path.
Typing the full path is optional IF you've been there before.

When typing in something that could be either one, APPDIR wins.

I guess putting my projects into identically named directories will have to change.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Unexpected shell behavior?

Post by broadblues »

xenic wrote:
nbache wrote:For some of us, it can be a mixed blessing, e.g. if you have to test different versions of the same program, then you have to make sure always to start them with explicit paths, even if you have one of them in your path (e.g. in your current dir).
It's actually a pain in the a** if you're using the SDK and AmiCygnix. There are same named commands in AmiCygnix:bin, SDK:local/C and system C: directories. I had to rename the AppDir directory in ENVARC: and create a file named AppDir in ENVARC: to disable AppDir: altogether.

AppDir may have seemed to be a good idea (and may be for some users) but it's pain for others. It would be nice to have some prefs where you could disable some commands or programs from being added to Appdir and the addition of a "noappdir" command to the system C directory.
Remove appdir: from the path in user startup and then you only have to worry about explicit references to appdir:someprog, these are usually deliberate and so not an issue. Dismemebering appdir completely is cutting off your nose because you want to get rid of a spot....
Post Reply