f



zsh: "export: not valid in this context"


I want the value of my environment variable GIT_PAGER to be set to
the string produced by =less followed by the string "${LESS}r",
where $LESS is a previously set variable.  In my current system,
the whole thing should amount to the string "/usr/bin/less -XFmij4r".

I can't figure out how to do this.  First, I don't know how to
interpolate =less directly into a string.  (Can it be done?)  So
I tried this ugly hack:

export GIT_PAGER=$(printf "%s %sr" =less $LESS)

....but I get the error

export: not valid in this context: -XFmij4r

How can I do this easily?

This question is motivated only by a desire to better understand
zsh (how to interpolate =cmd constructs, and how to understand the
export error above), rather than about how to solve this particular
problem, since I know that I can achieve the desired result by
first setting GIT_PAGER, and then exporting it.

TIA!

~kj
0
kj
11/29/2010 10:26:34 PM
comp.unix.shell 15484 articles. 3 followers. Post Follow

3 Replies
3475 Views

Similar Articles

[PageSpeed] 25

In article <id19aq$ku9$1@reader1.panix.com>, kj  <no.email@please.post> wrote:
>
>export GIT_PAGER=$(printf "%s %sr" =less $LESS)

The result of $() is subject to word splitting, resulting in this:

  export GIT_PAGER=/usr/bin/less -XFmij4r

where you meant to have:

  export GIT_PAGER="/usr/bin/less -XFmij4r"

So you're effectively trying to export 2 variables, one of which has a name
starting with a dash, and the shell refuses to do it.

Add some quotes, and it'll work:

export GIT_PAGER="$(printf "%s %sr" =less $LESS)"

The use of the =cmd construct didn't have anything to do with it.

-- 
Alan Curry
0
pacman
11/29/2010 11:35:22 PM
In <id1dbq$bho$1@speranza.aioe.org> pacman@kosh.dhis.org (Alan Curry) writes:

>In article <id19aq$ku9$1@reader1.panix.com>, kj  <no.email@please.post> wrote:
>>
>>export GIT_PAGER=$(printf "%s %sr" =less $LESS)

>The result of $() is subject to word splitting, resulting in this:

>  export GIT_PAGER=/usr/bin/less -XFmij4r

>where you meant to have:

>  export GIT_PAGER="/usr/bin/less -XFmij4r"

>So you're effectively trying to export 2 variables, one of which has a name
>starting with a dash, and the shell refuses to do it.

Ah, I get it.  Thanks!

~kj
0
kj
11/30/2010 3:16:18 AM
On 2010年11月30日 06:26, kj wrote:
> I want the value of my environment variable GIT_PAGER to be set to
> the string produced by =less followed by the string "${LESS}r",
> where $LESS is a previously set variable.  In my current system,
> the whole thing should amount to the string "/usr/bin/less -XFmij4r".
>
> I can't figure out how to do this.  First, I don't know how to
> interpolate =less directly into a string.  (Can it be done?)  So
> I tried this ugly hack:
>
> export GIT_PAGER=$(printf "%s %sr" =less $LESS)
>
> ...but I get the error
>
> export: not valid in this context: -XFmij4r
>
> How can I do this easily?
>
> This question is motivated only by a desire to better understand
> zsh (how to interpolate =cmd constructs, and how to understand the
> export error above), rather than about how to solve this particular
> problem, since I know that I can achieve the desired result by
> first setting GIT_PAGER, and then exporting it.
>
> TIA!
>
> ~kj
I don't know why you're not able to do it with printf,in my UBUNTU,it's OK.
Kins.

0
Kinsley
12/1/2010 1:33:00 AM
Reply:

Similar Artilces:

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

"valid users" / "users"
Hi, I have some problems in understanding the "users" and "valid users" directive correctly. My setup: [global] .... security = server password server = authserver username map = /etc/samba/users.map .... [BLAH] only user = yes printable = no comment = Projekte-Bereich BLAH browseable = no writable = yes force create mode = 0660 create mask = 0660 force directory mode = 2770 directory security mask = 2770 force directory security mode = 0000 directory mask = 2770 force security mode = 0000 security mask = 0770 force group = +blah path = /pro...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience working in UNIX environment. Good working knowledge of Oracle RDBMS and PL/SQL) Note : Please send your updated resume along with contact no to Karthik@bhaninfo.com. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com # 1572, 7 th Floor Suites, 1 Blue Hill Plaza Pearl River,NY-10965 www.bhaninfo.com ...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

puts "\\".gsub("\\", "\\\\")
Hello, I have a mini-ruby quiz. Guess what this line of code writes to the console, then try it for yourself: puts "\\".gsub("\\", "\\\\") Why is that so? Martin From: martinus [mailto:martin.ankerl@gmail.com]=20 # Hello, I have a mini-ruby quiz. Guess what this line of code writes to # the console, then try it for yourself: # puts "\\".gsub("\\", "\\\\") puts "\\".gsub("\\", "\\\\") \ #=3D> nil # Why is that so? faq. escaping the escape in sub/gsub. search the archives. maybe you want somethin...

There's "Unix", and then there's "UNIX(r)"
From TOW[1]: The Open Group, an industry standards consortium, now owns the UNIX trademark and allows its use for certified operating systems compliant with its standard, the Single UNIX Specification. Other operating systems that emulate Unix to some extent may be called Unix-like, although the Open Group disapproves of this term.[4] The term Unix is also often used informally to denote any operating system that closely resembles the trademarked system. The most common version of Unix (bearing certification) is Apple's OS X, while Linux is the most popular non-certified workalike. So, to summarize: "Unix" is a class of operating systems that is "UNIX-like", which includes Linux. "UNIX(r)" is a trademark of the Open group, who -- somewhat snootily -- have an issue with the term "UNIX-like". (They can take a flying fsck.) "Cult of Unix" spells "Unix" as "Unix", because otherwise, what would it have to do with Linux? This PSA brought to you by the letter "U" and the number "2". -v Unix minions, unite! On 2/9/14, 1:15 PM, in article ld8nlg$bu7$1@dont-email.me, "vallor" <vallor@cultnix.org> wrote: > From TOW[1]: > > The Open Group, an industry standards consortium, now owns the UNIX > trademark and allows its use for certified operating systems > compliant with its standard, the Single UN...

my own perl "dos->unix"/"unix->dos"
i made a dos to unix, unix to dos program catered for my own purposes. it's seems to work fine. small program, 26 lines anyone see any potential problems with it? do you have a better way to do it? my next step is to slip in some code to automatically "detect" whether its a unix or dos file. #!/usr/bin/perl -w use strict; #setting based on filename argument. # if sym link is dos-unix or if sym link is unix-dos my ($from, $to); my $option=substr($0,rindex($0,'/')+1,length($0)-1); # $0 gives full path. this code gives just filename if ($option eq "dos-unix"){ ...

What does "context push" do"
Hi, all I am now reading some scripts. I found many functions begin with the following line: context push -noverbose "[namespace current] $this [info level [info level]]" Before return there is a paired line: context pop -noverbose I am wordering what on earth these 2 lines do? Thanks and regards Victor Victor <bingc@lucent.com> wrote: > Hi, all > I am now reading some scripts. I found many functions begin with > the following line: > context push -noverbose "[namespace current] $this [info level [info level]]" > Before return there is a paired line: > context pop -noverbose > I am wordering what on earth these 2 lines do? "context" isn't a standard tcl command. It's either some extension your scripts load, or even a procedure defined in the script (or source'd in from another). From its usage, it appears to be a debugging helper. e.g. it collects information that might be used for problem analysis at some other point. Perhaps you find related lines either shortly after catch-handlers or in if-clauses that check the return value of previous commands. These lines will likely be the ones that use the information collected in these "context"-lines. Thanks, That it exactly an procedure defined somewhere else. It deals with context exchange. Victor Thanks, That it exactly an procedure defined somewhere else. It deals with context exchange. Victor ...

"A" is not equal "A"?
I was trying to convert String Array to String A through cycle and than compare the result with String B but eventhough results were the same it returned false. I'am working in BlueJ 3.1.0 Code is: public boolean Method () { String[] Example = {"a","b","c"}; String A = ""; String B = "abc" for (int i = 0; i<3 ; i++) { A = A + Example[i]; } if (A == B) { return true; } } never got true... I appreciate any suggestions how to solve this Den 08.04.2014 10:06, skrev 245dav@gmail.com:...

why have both "." and "->" ?
I used to remember why c++ needed both ? Could somebody help me here ? For example class A{ f(); }; A* aa; You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. Raj "raj" <rajkumar@hotmail.com> schreef in bericht news:d7fee6d0.0406230748.694b966b@posting.google.com... > I used to remember why c++ needed both ? > Could somebody help me here ? > > For example > > class A{ > f(); > }; > > A* aa; > > You could do either "aa->f()" or "(*aa).f()". So why does C++...

"==" is NOT TRUE "==", WHY?
[CODE START] x=5; y=8; if (x + y + 1E-15 == 13) a = 3 else a = 8 end [CODE END] When x + y + 1E-15, the code above returns a = 8. When x + y + 1E-16, the code above returns a = 3. Why? Kindly advise. Thanks. "onemilimeter Chen" <onemm@example.com> wrote in message <g7adrj$5tr$1@fred.mathworks.com>... > [CODE START] > x=5; > y=8; > if (x + y + 1E-15 == 13) > a = 3 > else > a = 8 > end > [CODE END] > > When x + y + 1E-15, the code above returns a = 8. > When x + y + 1E-16, the code above returns a = 3. > > Why? ...

Re: "out" and "in out"
"no reliable initial value" means, you cannot rely on the value, but it may have a value. This depends on the parameter passing mechanism, which is _not_ related to the parameter mode (contrary to what many people think). So the parameter mode is there (nearly) solely for the information of the reader. The parameter passing mechanism for all kinds of parameters is defined in the RM. There are parameters passed by copy (in and out), by reference; for some it is explicitly left undefined. In your case, the passing mechanism is by reference, so you get what you get. But don't rely...

what does the "+" and the "-" mean?
I recently read what the "+" and the "-" signs mean for compact discs. Of course, a friend has just asked me and I now forget. I've searched all over the place with no results. Anyone know? TIA! .. -------------------------------------- Mike Richter, were you born with "Scam Artist" emblazoned on your face? -------------------------------------- roscoe james wrote: > > I recently read what the "+" and the "-" signs mean for compact discs. Of > course, a friend h...

how to change "/" to "\"
iam new to shell scripting and i have plz can anyone help in changing the pattrern "/" to "\" using the sed command. olympie@gmail.com wrote: > iam new to shell scripting and i have plz can anyone help in changing > the pattrern "/" to "\" using the sed command. sed 's/\//\\/g' will replace all '/' with '\' srp -- http://saju.net.in Saju Pillai <saju.pillai@gmail.com> wrote: >> iam new to shell scripting and i have plz can anyone help in changing >> the pattrern "/" to "\" using ...

"plot", "imshow" and "quiver"
Hi all. So recently I made the discovery that when use "imshow" command, the YDir parameter under Axis Properties is set to "reverse" by default. To me this seems counter intuitive. Why wouldn't YDir be "normal" by default? When set at "normal" it turns out that my image is actually flipped upside down. On the contrary, when use "quiver" command to plot a vector field, the YDir is set at "normal" by default. Even though this makes more sense to me, because "reversed" YDir is the correct way to display an image (as in "imshow"), the result of "quiver" is that the vector fields this time depict the objects as if they are upside down... So every time I use "quiver" I always add the following line to revert the objects back to its normal orientation... set(gca, 'YDir', 'reverse')... In addition, "plot" uses "normal" setting for YDir. The only issue I have is that I use these commands fairly frequently in my job and sometimes they can get a little bit confusing in terms of display. So I wonder why MATLAB hasn't standardized them so that the objects always get displayed the same way. It's just a comment I have. Thank you. "Clare " <flyingclare@gmail.com> wrote in message news:hefvdk$3md$1@fred.mathworks.com... > Hi all. So recently I made the discovery that when use "imshow" command, > the ...

Is there any """Anti Stringizing operator #"""
Hi everybody:D I've a string that contains the name of a class. Some members told that I can use """Stringizing Operator (#)""", but the problem is here, that I have the string, & I want something vice- versa. As we know with """Stringizing Operator (#)""", we can get the stirng name of a class or ... str <--- #ClassA But I want to instantiate a class that I have just it's name as a string. ClassA * clsA = new ??? <--- Str ??? How can I do it? I don't want to use """HardCoding"&qu...

pasting "" and "" does not give a valid preprocessing token.
Hi all, I have a program as below: ----------- #include<stdio.h> #define FF(x,b) { \ struct ret *t; \ t->##x = b; \ } struct ret { int *a; }; int main() { int y =10,*g; struct ret *s; g =&y; FF(a,g); printf("val:%x %x\n",s->a,g); return 0; } --------------- When I compile I get the following error: field.c:17:1: pasting "->" and "a" does not give a valid preprocessing token I tried removing the ##,it compiled succesfully but I think doesnt solve my purpose. Can anyone please help in getting rid of this error? Am...

["a", "b", "c", "d"] to "a, b, c, d"?
I want to process each element of an array, but the last element should be handled special. Here is an example: def p_ary(ary) str = "" ary.each do |elem| str << elem << ", " end str.chomp!(", ") str end so p_ary(["a", "f", "x", "test"]) produces "a, f, x, test". The code works, but isn't there an easier and more general way for this behaviour? martinus On Tue, 06 Apr 2004 04:23:22 -0700, Martin wrote: > I want to process each element of an array, but the last ele...

Re: PROC EXPORT error "DBMS type EXCEL2000 not valid for export"
Change your DBMS option - DBMS=EXCEL is what I've been using successfully since moving to Office 2003. HTH, Carol Bristow 1655 N Fort Myer Dr Ste 925 Arlington, VA 22209 ph: 703.682.2612 fax: 703.528.3100 -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of JS Huang Sent: Friday, March 23, 2007 11:00 AM To: SAS-L@LISTSERV.UGA.EDU Subject: PROC EXPORT error "DBMS type EXCEL2000 not valid for export" Hi all: I tried to export a SAS dataset to EXCEL and got some error message: 1606 proc export 1607 data=BackDateInfo 1608 outfile="D:\BackDateInfo.XLS" 1609 DBMS=EXCEL2000 1610 replace; ERROR: DBMS type EXCEL2000 not valid for export. How do I fix it? I am using Excel Professional Edition 2003. Thanks! ...

Web resources about - zsh: "export: not valid in this context" - comp.unix.shell

Resources last updated: 3/18/2016 8:51:13 PM