I wrote a collection of bash functions years ago and now need to use them again but
I'm getting some error messages when eval tries to expand the variables names.
The problem is ~ is not being expanded. It turns out to be a little tricky to expand ~ but also avoid word separation on the path name (white spaces in you array source filename).
Try:
These 2 Users Gave Thanks to Chubler_XL For This Post:
I have a little script to help me manage a gallery of image files. It makes symbolic links to every file in and below the current directory, placing them in a target directory which is passed to the script as a parameter. Unfortunately, the script pukes when I pass a parameter that contains... (4 Replies)
If have
var='$variable'
how can I expand $variable.
I have tried many thing like duble quotes/braces etc, but nothing worked.
I need the solution ASAP. (2 Replies)
Hi,
The following code finds the line containing fruits in test.txt and replaces instances of apple with banana.
ed -s test.txt <<< $'/fruits/s/apple/banana/g\nw'
What I want to do is put variables in the place of fruits, apple and banana.
I have tried replacing ' with " to get... (2 Replies)
Hi,
I need some direction with the following. The below code is semi-psuedo code which will hopefully make it easier to understand what I am trying to achieve:
for i in `echo ${testarray
}`
do
let c=c+1
eval "first$c=$i"
while... (4 Replies)
Hello,
so i'm making a script, using dynamic variables and trying to expand them. So far it hasn't worked out too well so it seems that I need some help from you, the elite.
Example:
#!/bin/sh
counter=0
until (($counter>5))
counter2=1
until (($counter2>6)); do
if ;... (5 Replies)
Hi Guys,
I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need.
I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles.
... (3 Replies)
My OS is Linux (kernel 4.08.something) and AIX (7100-04-01-1543), the used ksh versions are:
ksh88: Version M-11/16/88f (AIX)
ksh93: Version M 93t+ 2009-05-01 (AIX), Version M 93u (Linux)
When writing a parser for stanza files in ksh i encountered a rather strange behavior. Here is a... (4 Replies)
I pass an argument to bash as run. The first command in green executes as expected, however the second in blue fails as the $run does not expand. I tried to escape the variable with \ thinking the quotes were making the literal translation and also "${run}" but both did not work to expand the... (3 Replies)
Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEUser3Contributed Perl DocuPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval(3pm)NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval - Write "eval { my $foo; bar($foo) }" instead of "eval "my $foo; bar($foo);"".
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
The string form of "eval" is recompiled every time it is executed, whereas the block form is only compiled once. Also, the string form
doesn't give compile-time warnings.
eval "print $foo"; # not ok
eval {print $foo}; # ok
CONFIGURATION
There is an "allow_includes" boolean option for this Policy. If set, then strings that look like they only include a single "use" or
"require" statement (with the possible following statement that consists of a single number) are allowed. With this option set, the
following are flagged as indicated:
eval 'use Foo'; # ok
eval 'require Foo'; # ok
eval "use $thingy;"; # ok
eval "require $thingy;"; # ok
eval "use $thingy; 1;"; # ok
eval "require $thingy; 1;"; # ok
eval 'use Foo; blah;'; # still not ok
eval 'require Foo; 2; 1;'; # still not ok
eval 'use $thingy;'; # still not ok
eval 'no Foo'; # still not ok
If you don't understand why the number is allowed, see Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval.
This option inspired by Ricardo SIGNES' Perl::Critic::Policy::Lax::ProhibitStringyEval::ExceptForRequire.
SEE ALSO
Perl::Critic::Policy::ControlStrucutres::RequireBlockGrep
Perl::Critic::Policy::ControlStrucutres::RequireBlockMap
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-06-07 Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval(3pm)