LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-07-2010, 06:35 AM   #1
__raHulk
Member
 
Registered: Apr 2010
Location: Mumbai
Distribution: RHEL, Debian, Fedora, Ubuntu
Posts: 39
Blog Entries: 1

Rep: Reputation: 16
The unusual/strange behaviors - Super Thread.


Hi Friends,

Recently I came upon a new discovery in bash shell that commands which expect input <paths> as parameters like ls, rm works even if you type multiple front slashes

for eg.
rm /foo/bar/file.txt
works even if we type it as
rm /foo//bar/file.txt

or even
ls /foo/////bar///file or to my surprise
even ///foo/bar/file.txt works.
I'm using RHEL 5.
Its a strange behaviour to me as I wonder why it happened. Could anyone explain it more deeply??...

Or if you too come across some strange things then do share it here as everyone would love to know such things ...
 
Old 05-07-2010, 07:28 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
It was UNIX behaviour, too, presumably because there is no ambiguity so there's no benefit (except pedantry) in rejecting paths with multiple consecutive "/" characters.
 
Old 05-07-2010, 07:31 AM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Here's a strange thing -- looking through zero reply threads and finding something labeled "Super Thread". A bit presumptuous, don't you think?

I tried your oddity in ksh on Solaris, and it works the same way.

I might have expected a syntax error, but, on the other hand, there's really no other interpretation. The extra / is either nothing or a syntax error.
 
Old 05-07-2010, 07:33 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: OpenSUSE 12.1 CentOS 6.2
Posts: 9,012

Rep: Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353Reputation: 1353
This behaviour is also defined by the POSIX standard, i.e. quoting the definition of PATHNAME from IEEE Std 1003.1-2001:
Quote:
A character string that is used to identify a file. In the context of IEEE Std 1003.1-2001, a pathname consists of, at most, {PATH_MAX} bytes, including the terminating null byte. It has an optional beginning slash, followed by zero or more filenames separated by slashes. A pathname may optionally contain one or more trailing slashes. Multiple successive slashes are considered to be the same as one slash.
 
1 members found this post helpful.
Old 05-07-2010, 12:14 PM   #5
__raHulk
Member
 
Registered: Apr 2010
Location: Mumbai
Distribution: RHEL, Debian, Fedora, Ubuntu
Posts: 39
Blog Entries: 1

Original Poster
Rep: Reputation: 16
Thanks colucix

Actually I came across this as I found that one of my scripts was not working properly; some of the lines are...

basepath=/backup/rman/
rm $basepath/arc*


While debugging I found that it actually expands to
rm /backup/rman//arc*
And I thought that I found the bug.

Then I executed rm /backup/rman//arc* from command prompt and it worked well (to my surprise).
BUT it was not working from inside the script which was scheduled by cron. This irritated me the most as the same command executes from the command line but not from within the script. This again is unusual...
 
  


Reply

Tags
super, unusual


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System Specs Super Thread lamar_air General 99 06-30-2010 03:55 AM
Strange behaviour from kernel thread lbdgwgt Programming 2 11-08-2007 01:32 AM
Strange Networking Problem (super slowness) starcastic Linux - Networking 13 03-02-2005 06:10 PM
super samba thread tendaas Linux - Newbie 1 09-15-2004 03:41 PM
Strange super-user problem Riichard Linux - Newbie 8 04-06-2004 04:24 PM


All times are GMT -5. The time now is 05:34 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration