LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 08-01-2012, 11:56 AM   #1
jcipale
LQ Newbie
 
Registered: Oct 2008
Posts: 9

Rep: Reputation: 0
Post Problem with '.' expansion in korn shell script


I have a script that compares two unique directories for common file variables/attributes. The script is executed as follows:
script_cmp.ksh <reference_path> <target_path>

If the user uses the full path for the <target_path> argument, the script works correctly and displays the information (validated previously during development). If I allow the user to either pass in a '.' (for PWD) or leave the 2nd argument empty (assuming PWD), the data that is returned is incorrect compared to the known and validated good data.

Is there an unknown 'gotcha' I need to be aware of with regards to expanding the '.' in a script? Thanks!
 
Old 08-01-2012, 12:31 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
I believe you can use the BASH_SOURCE variable within bash scripts to get this info, but not sure if it will work within korn shell.

http://www.gnu.org/software/bash/man...Variables.html

Last edited by Kustom42; 08-01-2012 at 12:34 PM.
 
Old 08-01-2012, 12:39 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
It might help if you posted some, you know, actual code. Then we might be able to spot the error.

Also, be aware that "." and ".." are not aliases or shortcuts or anything. They are real directory names, produced by the underlying filesystem to point to the current and parent directories. The shell you use has nothing to do with their definition, and should generally handle them just like any other path name, although it may be configured to treat them specially in some circumstances (ignoring them in globs, for example).
 
Old 08-01-2012, 12:47 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Kustom42 View Post
I believe you can use the BASH_SOURCE variable within bash scripts to get this info, but not sure if it will work within korn shell.

http://www.gnu.org/software/bash/man...Variables.html
I don't understand how this relates to the OP's question. On my system, "FUNCNAME" is empty, but pwd and "." (meaning "current directory") still works.

For the OP:
In normal ksh file operations, does "." work to signify current directory? If so, then you may need to use quotes somewhere to keep it from being seen as a regex meaning "any character".

Last edited by pixellany; 08-01-2012 at 12:55 PM.
 
  


Reply



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
Need File Name comparison help on Korn Shell Script confusiac437 Programming 7 07-01-2011 02:14 PM
Korn Shell problem / User Monitoring script Fragments Programming 1 03-18-2010 07:09 AM
Korn shell script mmahulo Linux - Newbie 9 12-17-2008 09:19 AM
script in korn shell disruptive Programming 15 02-22-2007 10:18 AM
Korn shell script Muzica Solaris / OpenSolaris 4 09-06-2004 12:47 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 01:22 PM.

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