Sponsored Content
Full Discussion: $- parameter ...
Top Forums UNIX for Dummies Questions & Answers $- parameter ... Post 62040 by moxxx68 on Thursday 10th of February 2005 05:14:29 PM
Old 02-10-2005
Question $- parameter ...

I have an excert from the Rute Tutorial and Expo by paul sheer... about parameters.. so far I have understood most of them .. except this one:
"$-
Expands to the current option flags as specified upon invocation, by the set builtin command, or those set by the shell itself (such as the -i option)." (by paul sheer Author of Rute Tutorial and Expo).....
when I excute this command on the command line I get this;
echo $-
himBH
if any could clarify this it would greatly be appreciated.. .
moxxx68

Last edited by moxxx68; 02-10-2005 at 06:19 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parameter

I need to pass a filename parameter in shell script and then need to validate same name in the folder, Can any one help what would be piece of code to do so. Lets folder is a and file with a is test.dat and i want to pass this parameter against the file name file_name and then want to compare... (5 Replies)
Discussion started by: u263066
5 Replies

2. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies

3. Shell Programming and Scripting

use $1 parameter

Hi, I have a script and I'm passing in a parmeter $1, and I only what to pass this $1 parmeter into another script. Please see below for details for help : virtual_gateway="$1" YYYYMMDD="`date +%Y%m%d`" ... (7 Replies)
Discussion started by: venhart
7 Replies

4. UNIX for Dummies Questions & Answers

how to get $1 parameter in ~/.bashrc

Hi, i am trying to convert windows path to linux and do some action on equivalent mounted one for the same in linux. echo '\\server1\source\path\needed_files' | sed -e 's!\\!/!g' | sed -e 's!^//!/!' | sed -e 's!\(/server1/source/path\)\(.*\)!/home/$USER/mount/server1\2!'output: ... (5 Replies)
Discussion started by: greet_sed
5 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

7. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

8. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

9. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

10. Shell Programming and Scripting

Use parameter expansion over a parameter expansion in bash.

Hello All, Could you please do help me here as I would like to perform parameter expansion in shell over a parameter expansion. Let's say I have following variable. path="/var/talend/nat/cdc" Now to get only nat I could do following. path1="${path%/*}" path1="${path1##*/}" Here... (8 Replies)
Discussion started by: RavinderSingh13
8 Replies
MooseX::Role::Parameterized::Tutorial(3)		User Contributed Perl Documentation		  MooseX::Role::Parameterized::Tutorial(3)

NAME
MooseX::Role::Parameterized::Tutorial - why and how MOTIVATION
Roles are composable units of behavior. They are useful for factoring out functionality common to many classes from any part of your class hierarchy. See Moose::Cookbook::Roles::Recipe1 for an introduction to Moose::Role. While combining roles affords you a great deal of flexibility, individual roles have very little in the way of configurability. Core Moose provides "-alias" for renaming methods and "-excludes" for ignoring methods. These options are primarily for resolving role conflicts. Depending on how much of a purist you are, these options are solely for resolving role conflicts. See Moose::Cookbook::Roles::Recipe2 for more about "-alias" and "-excludes". Because roles serve many different masters, they usually provide only the least common denominator of functionality. To empower roles further, more configurability than "-alias" and "-excludes" is required. Perhaps your role needs to know which method to call when it is done processing. Or what default value to use for its "url" attribute. Parameterized roles offer a solution to these (and other) kinds of problems. USAGE
"with" The syntax of a class consuming a parameterized role has not changed from the standard "with". You pass in parameters just like you pass in "-alias" and "-excludes" to ordinary roles (though your custom parameters do not get hyphens, since these are not core Moose composition parameters): with 'MyRole::InstrumentMethod' => { method_name => 'dbh_do', log_to => 'query.log', }; You can still combine parameterized roles. You just need to specify parameters immediately after the role they belong to: with ( 'My::Parameterized::Role' => { needs_better_example => 1, }, 'My::Other::Role', ); We, like Moose itself, use Data::OptList to make sure that a list of role names and associated parameters is handled correctly. "parameter" Inside your parameterized role, you specify a set of parameters. This is exactly like specifying the attributes of a class. Instead of "has" in Moose you use the keyword "parameter", but your parameters can use any options to "has". parameter 'delegation' => ( isa => 'HashRef|ArrayRef|RegexpRef', predicate => 'has_delegation', ); You do have to declare what parameters you accept, just like you have to declare what attributes you accept for regular Moose objects. One departure from "has" is that we create a reader accessor for you by default. In other words, we assume "is => 'ro'". We create this reader for convenience because generally the parameterized role is the only consumer of the parameters object, so data hiding is not as important than in the general case of "has" in Moose. If you do not want an accessor, you can use "is => 'bare'". "role" "role" takes a block of code that will be used to generate your role with its parameters bound. Here is where you declare components that depend on parameters. You can declare attributes, methods, modifiers, etc. The first argument to the "role" is an object containing the parameters specified by "with". You can access the parameters just like regular attributes on that object. Each time you compose this parameterized role, the "role {}" block will be executed. It will receive a new parameter object and produce an entirely new role. That's the whole point, after all. Due to limitations inherent in Perl, you must declare methods with "method name => sub { ... }" instead of the usual "sub name { ... }". Your methods may, of course, close over the parameter object. This means that your methods may use parameters however they wish! USES
Ideally these will become fully-explained examples in something resembling Moose::Cookbook. But for now, only a braindump. Configure a role's attributes You can rename methods with core Moose, but now you can rename attributes. You can now also choose type, default value, whether it's required, traits, etc. parameter traits => ( isa => 'ArrayRef', default => sub { [] }, ); parameter type => ( isa => 'Str', default => 'Any', ); role { my $p = shift; has action => ( traits => $p->traits, isa => $p->type, ... ); } Inform a role of your class' attributes and methods Core roles can only require methods with specific names chosen by the role. Now your roles can demand that the class specifies a method name you wish the role to instrument, or which attributes to dump to a file. parameter instrument_method => ( isa => 'Str', required => 1, ); role { my $p = shift; around $p->instrument_method => sub { ... }; } Arbitrary execution choices Your role may be able to provide configuration in how the role's methods operate. For example, you can tell the role whether to save intermediate states. parameter save_intermediate => ( isa => 'Bool', default => 0, ); role { my $p = shift; method process => sub { ... if ($p->save_intermediate) { ... } ... }; } Deciding a backend Your role may be able to freeze and thaw your instances using YAML, JSON, Storable. Which backend to use can be a parameter. parameter format => ( isa => (enum ['Storable', 'YAML', 'JSON']), default => 'Storable', ); role { my $p = shift; if ($p->format eq 'Storable') { method freeze => &Storable::freeze; method thaw => &Storable::thaw; } elsif ($p->format eq 'YAML') { method freeze => &YAML::Dump; method thaw => &YAML::Load; } ... } Additional validation Ordinary roles can require that its consumers have a particular list of method names. Since parameterized roles have direct access to its consumer, you can inspect it and throw errors if the consumer does not meet your needs. role { my $p = shift; my %args = @_; my $consumer = $args{consumer}; $consumer->find_attribute_by_name('stack') or confess "You must have a 'stack' attribute"; my $push = $consumer->find_method_by_name('push') or confess "You must have a 'push' method"; my $params = $push->parsed_signature->positional_params->params; @$params == 1 or confess "Your push method must take a single parameter"; $params->[0]->sigil eq '$' or confess "Your push parameter must be a scalar"; ... } perl v5.18.2 2012-08-14 MooseX::Role::Parameterized::Tutorial(3)
All times are GMT -4. The time now is 02:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy