WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] cd -- might not be a bug?  (Read 2076 times)

aus9

  • Guest
[SOLVED] cd -- might not be a bug?
« on: April 21, 2013, 04:25:52 AM »
Hi

I am reluctant to call it a bug, but I find it equally bugging me so thought I would report it in case its fixable.

I can easily reproduce it.

In terminal I define a variable, lets call it

SRC=cups-1.6.2

If I forget to define it, and its real pathway is  /tmp/cups-1.6.2
and I am currently in /tmp

Code: [Select]
cd $SRC

kicks me back into either home folder for the user

eg for root
Code: [Select]
root@box:/tmp# pwd
/tmp
root@box:/tmp# cd $SRC
root@box:~# pwd
/root

for tc

Code: [Select]
tc@box:/tmp$ pwd
/tmp
tc@box:/tmp$ cd $SRC
tc@box:~$ pwd
/home/tc

I know the primary error is the idiot typing at the moment

###########
FEATURE request
###########
Any chance of some kind of feature request to stop the kick back into the relevant home folder?

thanks for reading
« Last Edit: April 21, 2013, 07:43:40 AM by aus9 »

Offline AmatCoder

  • Full Member
  • ***
  • Posts: 179
    • AmatCoder Projects
Re: cd -- might be a bug?
« Reply #1 on: April 21, 2013, 05:49:48 AM »
If $SRC is empty then cd is executed with no arguments. And when cd is executed without arguments the user is returned to the home directory.

It is normal behavior, not bug.

Offline AmatCoder

  • Full Member
  • ***
  • Posts: 179
    • AmatCoder Projects
Re: cd -- might be a bug?
« Reply #2 on: April 21, 2013, 06:06:23 AM »
Any chance of some kind of feature request to stop the kick back into the relevant home folder?

Code: [Select]
$ cd ${SRC?Error}
This gives you an error if $SCR variable is not defined and lets you where you are at.

aus9

  • Guest
Re: [SOLVED] cd -- might not be a bug?
« Reply #3 on: April 21, 2013, 07:44:45 AM »
AmatCoder


Thanks for the quick reply, I thought that might be the case but doesn't hurt to ask eh?

marked as solved

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: cd -- might be a bug?
« Reply #4 on: April 21, 2013, 11:18:23 AM »

Code: [Select]
$ cd ${SRC?Error}
This gives you an error if $SCR variable is not defined and lets you where you are at.

Adding this to my growing IUSILFTF list.  Thank you.

"Incredibly Useful S(tuff) I've Learned From These Forums"
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar