WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Possible .ashrc bugs -- editor  (Read 2844 times)

Offline moB

  • Newbie
  • *
  • Posts: 49
Possible .ashrc bugs -- editor
« on: May 29, 2014, 07:13:57 PM »
There is questionable code in .ashrc

Code: [Select]
export EDITOR

# should be ?
export EDITOR=$EDITOR

Test: "echo $EDITOR" - does not agree with "which editor"

Returning "editor" does not work in all instances, crontab -e, for example.

Code: [Select]
tc@box:~$ which editor
/usr/local/bin/editor
tc@box:~$ crontab -e
crontab: can't execute 'editor': No such file or directory
tc@box:~$ echo $EDITOR
editor
# No path - so it is not found when crontab call it

Set environmental variable for the terminal session manually as a test:

Code: [Select]
tc@box:~$ export EDITOR=vi
tc@box:~$ echo $EDITOR
vi
tc@box:~$ export EDITOR=$(which vi)
tc@box:~$ echo $EDITOR
/usr/bin/vi
tc@box:~$ crontab -e
# Both above can opens vi for editing crontab

Perhaps if the startup script had export EDITOR=`which editor`?
That saves one unneeded temporary variable: "editor".

Code: [Select]
tc@box:~$ export EDITOR=`which editor`
tc@box:~$ echo $EDITOR
/usr/local/bin/editor
#
# More correct alternative? Also works
tc@box:~$ export TERM=$(which editor)
tc@box:~$ echo $EDITOR
/usr/local/bin/editor

After that "crontab -e" will open editor, not vi, nor fail.

Another route is to leave setup options in .ashrc:

Code: [Select]
# with optional editor in comment
# text-editor=vi
text-editor=editor
export EDITOR=$(which $text-editor)

This also works. Maybe less vague to call the temp var text-editor?


        -----------------------------------------------------------------------------------------------------------------


Maybe this belongs in another post... but here we go.
In some other config file we have a similar misconfiguration.

Code: [Select]
echo $TERM
rxvt
echo $COLORTERM
rxvt


The env. var: is set: COLORTERM='rxvt'

Similar to above, we see the problem.

Code: [Select]
tc@box:~$ echo $TERM
rxvt
tc@box:~$ echo $COLORTERM
rxvt
tc@box:~$ which term
tc@box:~$ which rxvt
tc@box:~$ rxvt
sh: rxvt: not found
tc@box:~$ which aterm
/usr/local/bin/aterm


EnvVar should be aterm? Currently sets by default to rxvt.

This causes me to get term instances named rxvt from time to time,
though it's usually named Terminal. A trivial error, but it bugs me :-P


This might be a remedy:

Code: [Select]
tc@box:~$ export TERM=$(which aterm)
# and this?
tc@box:~$ export COLORTERM=$TERM


Musing....
I know the debain term (on antiX) has sytax coloring.
Is that a (sic) real "COLORTERM"?


OK, enough for now.  No biggie.

moB (having a whale of a time)


ps Love the development of Core/TC!

Keep up the good work.  :)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Possible .ashrc bugs -- editor
« Reply #1 on: May 29, 2014, 07:25:12 PM »
The .ashrc is correct.
export EDITOR
will export the EDITOR variable with its current value.
export EDITOR=vi
will assign the value of 'vi' and export the EDITOR variable.

Offline moB

  • Newbie
  • *
  • Posts: 49
Re: Possible .ashrc bugs -- editor
« Reply #2 on: May 29, 2014, 07:44:54 PM »
Thanks
 for quick reply gerald_clark!

I still get error:

Code: [Select]
tc@box:~$ crontab -e
crontab: can't execute 'editor': No such file or directory
tc@box:~$

Which is remedied by:

Code: [Select]
then
# editor if xwin - with path - if fails to find editor use vi
        EDITOR=$(which editor) || EDITOR=$(which vi)
else
# editor if nox
        EDITOR=$(which vi)
fi
export EDITOR



Works here, so far. (Did not yet test nox portion.)

Seems I needed the full path (from which). Spelling editr in part one
makes xwin editor vi, so which still tests for installed graphical text
app as in default (5 may 2013 len version).

Code: [Select]
# test to force vi in xwin
       editor=$(which editr) || editor=$(which vi)


You are right about not needing the export "EDITOR=..." stuff. You know
this, but I'd like to agree :)



edit: [ soooo many spelling corrections]
« Last Edit: May 29, 2014, 09:48:03 PM by moB »

Offline moB

  • Newbie
  • *
  • Posts: 49
Re: Possible .ashrc bugs -- editor
« Reply #3 on: May 29, 2014, 09:53:08 PM »
Works well.


Code: [Select]
if [ -n "$DISPLAY" ]
then
# editor if xwin - with path
        EDITOR=$(which editor) || EDITOR=vi         
else
# editor if nox
        EDITOR=vi         
fi
export EDITOR


Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Possible .ashrc bugs -- editor
« Reply #4 on: May 30, 2014, 08:28:13 AM »
The TERM variables are also correct. aterm uses rxvt colors, there is no aterm terminal definition.

Crontab not opening editor from /usr/local is a bb quirk. As a security measure, some suid apps' PATH and other env vars get reset. We will need to add /usr/local to the default root path next bb build.
The only barriers that can stop you are the ones you create yourself.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Possible .ashrc bugs -- editor
« Reply #5 on: May 30, 2014, 10:29:17 AM »
I haven't really understood why one would by default end up with TERM=rxvt when using aterm.

Empirically it appears to me I get more satisfying behavior when setting TERM=xterm in aterm before attaching to 'screen'.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)