"env" variable problem? [ Solved ]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#16 Post by Karl Godt »

jpeps wrote:Check what shell you're using: "ps | grep $$"

Code: Select all

echo $0
instead of $$

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#17 Post by Karl Godt »

there are configfiles .Xresources and .Xdefaults .

mrxvt also has a .mrxvtrc configfile i think .

not sure about rxvt/urxvt .

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#18 Post by sunburnt »

SOLVED.!

It seems that I found at least "one" variable that won`t work. Lucky me...

First the variable APP_LIB worked fine, so I got suspicious.
I changed APP_DIR to APPDIR and it works fine.
I`m guessing that App_Dir would probably work also.

There`s a few existing env variables that have _DIRS or DIR in them:

Code: Select all

XDG_CONFIG_DIRS=/etc/xdg
XDG_DATA_DIRS=/usr/share:/usr/local/share
XFINANSDIR=/root/.xfinans
But it doesn`t seem that there would be a name space conflict here.
Odd.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#19 Post by Karl Godt »

maybe it had been

Code: Select all

App _Dir
(space) (typo) ?

Don't know if such things would break login
ie
App _Dir=/path
login App : command not found
.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#20 Post by sunburnt »

No, I rewrote it so many times, it couldn`t have been wrong all of them.
You could try setting APP_DIR in profile.local and see if it does it for you.

The results are consistent, something just doesn`t like _DIR .
The new variables APPDIR and APPLIB work very well.
So I don`t have a broken system after all.
At least not any more broken than Puppy and Linux are already. :wink:

Thanks Karl and everyone... Terry

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#21 Post by jpeps »

sunburnt wrote: At least not any more broken than Puppy and Linux are already. :wink:
...except the problem isn't Puppy or Linux

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#22 Post by technosaurus »

Is /bin/sh pointing to bash or busybox and do you have stock puppy bash, because bash can be configured to have different behavior when called as sh.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#23 Post by Karl Godt »

technosaurus wrote:Is /bin/sh pointing to bash or busybox and do you have stock puppy bash, because bash can be configured to have different behavior when called as sh.
Yes i noticed this at the prompt .
Though autologin/login the prompt semms to be different on / and on /root .

Also using vi or vim keyboard behavior acts different . To get tab auto completion i need to type bash at the prompt, otherwise i get

# ls--->
instead of
# ls
ls
lspci

:lol:

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#24 Post by sunburnt »

Hi jpeps; Do you know what the problem is?
I figured it was something in the env handling that didn`t like what it thought were dups.
It seems to be the case anyway.

Yo... technosaurus; Stock Lucid Puppy528-005 bash, and /bin/sh => /bin/bash

I`ll look at configuring bash, we`ve been trying to do that in another thread.
Wanted 3 CLI behaviors, mime, run RoxApps, and a multi. link junction.
All currently use a script, but all have to be built-in bash behaviors.

Hey Karl; Different behaviors at different times shows there`s a lot going on. Simplify!

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#25 Post by jamesbond »

APP_DIR is eaten by Rox. From ROX changelog:

Code: Select all

21-Jul-2000
~~~~~~~~~~~
In the path entry minibuffer, an exact match is favoured over any other
match. So, if you enter '.xsession' and press Return you'll get it, not
'.xsession-errors' or whatever!

The filer now clears APP_DIR from the environment so that child processes
don't get it. Fixed a bug which caused problems when using a small version
of the 'missing image' image.
If you launch terminal (rxvt) *NOT* from Rox, but from elsewhere (e.g. from JWM / menu) by choosing JWM menu --> terminal, you will see your APP_DIR is still there :D
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#26 Post by jpeps »

sunburnt wrote:Hi jpeps; Do you know what the problem is?
You have to use unique variable names. APP_DIR is probably used by something else. If people gives examples that work, it's a good idea to try the posted code.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#27 Post by sunburnt »

jpeps; I think jamesbond has nailed it... Kinda what I was saying.

jamesbond; I figured APP_DIR still existed, just a different shell than rxvt.

Goes along with my statement that there`s lots going on.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#28 Post by jpeps »

APP_DIR will work as an alias in .bashrc, but doesn't work as a variable name in the /etc/init.d folder. It doesn't matter how or what terminal you load, or what shell you are in. To me, that means it's a reserved variable name.


"Variable names

Since all reserved variables are UPPERCASE, the safest way is to only use lowercase variable names. This is true for reading user input, loop counting variables, etc., … (in the example: file)

prefer lowercase variables
if you use UPPERCASE names, do not use reserved variable names (see SUS for an incomplete list)
if you use UPPERCASE names, at best prepend the name with a unique prefix (MY_ in the example below"

http://wiki.bash-hackers.org/scripting/style

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#29 Post by sunburnt »

Makes sense, I usually use leading capitals, so that works well.

This is the first time I`ve run into a name space problem like this.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#30 Post by amigo »

In order for any variable to be available in the environment in which a program runs, it has to be exported properly, or passed on the command line before the call to the program:

Code: Select all

unset APP_DIR
export APP_DIR
program-to run
# or:
APP_DIR=/path/to/somewhere program-to-run
Unsetting cleans up any existing APP_DIR value. APP_DIR is not a 'proprietary' enivronmental variable.

Why don't you simply get and use APP_DIR as the current directory. When an AppRun script is run it can find out where it is at:

Code: Select all

# Check for links and get APP_DIR
if [ ! -L "$0" ] ; then
	APP_DIR=`dirname "$0"`
	APP_DIR=`cd "$APP_DIR";pwd`
elif [ ! -z `which readlink 2> /dev/null` ] ; then
	APP_DIR=`readlink -f "$0"`
	APP_DIR=`dirname "$APP_DIR"`
else
	echo "$PROG: Can't get real path to AppRun!" 1>&2
fi
export APP_DIR

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#31 Post by sunburnt »

Hi amigo; That`s what I`m doing for AppDir, but AppLib is different.
It contains all the shared libs. for the AppDir apps.
It`s just adding a few more variables to the config. file to have AppDir.
There can be many AppDir dirs. for apps., but only one AppLib so far.

I renamed APP_DIR to AppDir as the ROX-Filer uses $APP_DIR.

Reading the config. file for each app. start isn`t so bad. But not good...


# I`m still trying to find a "one method fits all" for no-install apps.
The chroot idea is interesting, but I`m a little confused on how to do it.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#32 Post by Flash »

"The beautiful thing about standards is that there so many to choose from." :lol:

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#33 Post by jpeps »

amigo wrote: APP_DIR is not a 'proprietary' enivronmental variable.
It doesn't work from /etc/init.d. Unsetting it first doesn't work either. There's no problem using it as a local variable.

edit: I got it to work by getting out of my user shell into root. Interestingly, my unset command also only works from root shell. If running from root, the unset command isn't even needed.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#34 Post by sunburnt »

jamesbond found it...

ROX-Filer sets: APP_DIR='' when it`s started.

So in the ROX desktop env APP_DIR gets trashed.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#35 Post by jpeps »

sunburnt wrote:
So in the ROX desktop env APP_DIR gets trashed.
May be one example of the dangers of running in /root.

Post Reply