LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
  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: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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,197

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
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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

Original Poster
Blog Entries: 1

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



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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:02 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration