Sponsored Content
Top Forums Shell Programming and Scripting Commenting out "expr" creates weird behavior Post 302873167 by alister on Monday 11th of November 2013 09:06:32 AM
Old 11-11-2013
Quote:
Originally Posted by royalibrahim
Even if I explicitly comment out the line containing the expr using "#", the error message would still exist
A heredoc isn't a shell script. Since there are no comments within a heredoc, # is not a special character.

Regards,
Alister
This User Gave Thanks to alister For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Weird problem with output from "date '+3600*%H+60*%M+%S' "

Hi, I came across a script a few months ago that allowed you to use the following script to include the current time into your prompt (useful from auditting purposes): # Set Prompt typeset -RZ2 _x1 _x2 _x3 let SECONDS=$(date '+3600*%H+60*%M+%S')... (5 Replies)
Discussion started by: m223464
5 Replies

2. Shell Programming and Scripting

why "expr "${REPLY}" : '\([1-9][[:digit:]]*\)" can figure out whether it is a digit?

I found below script to check whether the variable is a digit in ksh. ############################ #!/bin/ksh REPLY="3f" if ]*\)'` != ${REPLY} && "${REPLY}" != "0" ]] then print "is digit\n" else print "not digit\n" fi ############################ Although it works fine, but... (6 Replies)
Discussion started by: sleepy_11
6 Replies

3. Shell Programming and Scripting

HowTo: reg expr doing grep "timestamp>$DesiredTime" logfile ?

I know I asked a similar question but I want to know if there is a regular expression existing that with a korn shell cmd, finds any timestamp data records in a file where it is greater then a timestamp in a shell variable ? something like : grep all records where it has a timestamp >... (5 Replies)
Discussion started by: Browser_ice
5 Replies

4. Shell Programming and Scripting

convert a=(b/100)*a into a "expr" expression

Hi Guys, THis is the first time am using the expr expression. I like to know how to write the expression a=(b\100)*a. THis works fine if it gives without a bracket. the bracket should be present as i wanted to define the order of execution. Help me out. Thanks for your help in advance.... (2 Replies)
Discussion started by: mac4rfree
2 Replies

5. Shell Programming and Scripting

"Odd" behavior exiting shell script

Is it normal behavior for a shell script that terminates to terminate its parent shell when executed with the "." option? For example, if I have the example script (we'll name it ex.sh): #!/bin/sh if then echo "Bye." exit 2 fi And I execute it like this: >./ex.sh It... (6 Replies)
Discussion started by: DreamWarrior
6 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Advanced & Expert Users

"╭─ " Character combo in $PATH causes strange autocompletion behavior in zsh

I've posted about this before, but only recently narrowed the problem down to a specific cause. Ok, first of all, the behavior: It occurs when autocompletion brings up its list (not when there is only a single option). Basically, if I were to type, say, cd ~/<TAB> I would get something... (2 Replies)
Discussion started by: marshaul
2 Replies

8. UNIX for Advanced & Expert Users

Weird "sort" behavior

Hi, I'm trying to sort a text file "test": S12 S_S12 S_S1_12 S15 S_N15 S_N1_15 By "sort test", I get: S12 S15 S_N1_15 S_N15 S_S1_12 S_S12 It seems weird: Comparing Line 2 and Line 3, it must be that '-' is bigger than '1'; however, comparing Line 3 and Line 4, it seems that... (3 Replies)
Discussion started by: intermilan
3 Replies

9. Homework & Coursework Questions

How to lclear "expr: syntax error" eventhough everything looks fine?

Hi All, As per my knowledge in unix, my code looks fine. But still I am getting error (expr:syntax error). Please help me to resolve this error. Script : PRE_LBNO=0 PRE_DATE=0 TOT_PAY=0 TOT_REM=0 TOTAL=1 for Record_Type in `cut -c 1 Inputt.dat` do if ; then CURR_LBNO=` cut -c... (6 Replies)
Discussion started by: lathanandhini
6 Replies

10. Shell Programming and Scripting

Weird behavior of command "local"

Hi there, I'm running into a very weird situation. Let's forget about the purpose of my initial script please. I noticed the bug whatever I'm trying to do. I'm on an old server running bash 3.1.17. Say we have the following script : foo:~# cat /tmp/test #!/bin/bash f1() { local... (9 Replies)
Discussion started by: chebarbudo
9 Replies
PPI::Token::HereDoc(3)					User Contributed Perl Documentation				    PPI::Token::HereDoc(3)

NAME
PPI::Token::HereDoc - Token class for the here-doc INHERITANCE
PPI::Token::HereDoc isa PPI::Token isa PPI::Element DESCRIPTION
Here-docs are incredibly handy when writing Perl, but incredibly tricky when parsing it, primarily because they don't follow the general flow of input. They jump ahead and nab lines directly off the input buffer. Whitespace and newlines may not matter in most Perl code, but they matter in here-docs. They are also tricky to store as an object. They look sort of like an operator and a string, but they don't act like it. And they have a second section that should be something like a separate token, but isn't because a strong can span from above the here-doc content to below it. So when parsing, this is what we do. Firstly, the PPI::Token::HereDoc object, does not represent the "<<" operator, or the "END_FLAG", or the content, or even the terminator. It represents all of them at once. The token itself has only the declaration part as its "content". # This is what the content of a HereDoc token is <<FOO # Or this <<"FOO" # Or even this << 'FOO' That is, the "operator", any whitespace separator, and the quoted or bare terminator. So when you call the "content" method on a HereDoc token, you get '<< "FOO"'. As for the content and the terminator, when treated purely in "content" terms they do not exist. The content is made available with the "heredoc" method, and the name of the terminator with the "terminator" method. To make things work in the way you expect, PPI has to play some games when doing line/column location calculation for tokens, and also during the content parsing and generation processes. Documents cannot simply by recreated by stitching together the token contents, and involve a somewhat more expensive procedure, but the extra expense should be relatively negligible unless you are doing huge quantities of them. Please note that due to the immature nature of PPI in general, we expect "HereDocs" to be a rich (bad) source of corner-case bugs for quite a while, but for the most part they should more or less DWYM. Comparison to other string types Although technically it can be considered a quote, for the time being "HereDocs" are being treated as a completely separate "Token" subclass, and will not be found in a search for PPI::Token::Quote or "PPI::Token::QuoteLike objects". This may change in the future, with it most likely to end up under QuoteLike. METHODS
Although it has the standard set of "Token" methods, "HereDoc" objects have a relatively large number of unique methods all of their own. heredoc The "heredoc" method is the authoritative method for accessing the contents of the "HereDoc" object. It returns the contents of the here-doc as a list of newline-terminated strings. If called in scalar context, it returns the number of lines in the here-doc, excluding the terminator line. terminator The "terminator" method returns the name of the terminating string for the here-doc. Returns the terminating string as an unescaped string (in the rare case the terminator has an escaped quote in it). TO DO
- Implement PPI::Token::Quote interface compatibility - Check CPAN for any use of the null here-doc or here-doc-in-s///e - Add support for the null here-doc - Add support for here-doc in s///e SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2011-02-26 PPI::Token::HereDoc(3)
All times are GMT -4. The time now is 11:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy