GitHub Wiki markdown editing: how to avoid substitution of "\033"? [closed] - github

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am editing a Wiki page on GitHub using the Markdown edit mode and trying to insert a block of code form a shell script as follows:
```
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
```
However, the block ends up looking like this instead:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[SAME-43-CHAR-SEQUENCE[01;32m\]\u#\h\[SAME-43-CHAR-SEQUENCE[00m\]:\[SAME-43-CHAR-SEQUENCE[01;34m\]\w\[SAME-43-CHAR-SEQUENCE[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi
So it looks like it's interpreting the char sequence \033 as some sort of code SAME-43-CHAR-SEQUENCE which looks like some sort of UUID. How can I avoid that? Thx

Escaping the slash with another slash seems to work.
So, change \033 to \\033
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\\033[01;32m\]\u#\h\[\\033[00m\]:\[\\033[01;34m\]\w\[\\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u#\h:\w\$ '
fi

Related

Awk command to powershell [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hi i try to transcript an awk command to powershell
i have a text file
SQLBefore:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_CHK=SYSTIMESTAMP
, S1_FLWUP_DATE_LAST=NULL
WHERE S1_FLWUP_NAME='GGGGG_ETAT_JJ'
SQLAfter:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_LAST=SYSTIMESTAMP
, S1_FLWUP_STAT_SID=1
WHERE S1_FLWUP_NAME='TTTTT_ETAT_'
SQLFailed:=
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_LAST=S1_FLWUP_DATE_FRST
, S1_FLWUP_STAT_SID=3
WHERE S1_FLWUP_NAME='JJJJ_ETAT_JJJ'
And i would like to do the same than this unix command in powershell
cat $this_file|awk '/SQLAfter/,/SQLFailed/ {print $0}'| grep -v SQL|sed -e 's/^$//'
It's return
UPDATE SYSADM.PS_S1_R_FLWUP
SET S1_FLWUP_DATE_CHK=SYSTIMESTAMP
, S1_FLWUP_DATE_LAST=NULL
WHERE S1_FLWUP_NAME='GGGGG_ETAT_JJ'
I'm getting stuck to do the delimiter like awk, between "SQLBefore:=" and "SQLAfter:=" with powershell
Thanks for your help.
I'm a beginner of powershell sorry for my english
One possibility, assuming I'm reading the question correctly (however "bad" you think your English might be I assure you it's considerably better than my AWK).
((get-content testfile.txt -raw) -split 'SQL(?:Before|After):=')[1]

Detect letter where number was expected [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How can I detect and show an error if someone put a letter and the program expects a number?
A regexp match makes this easy. Searching for any character which isn't a numeral or an arithmetic symbol:
if ( $input =~ /[^0-9+*/-]/ ) {
print "Incorrect character detected!\n"
}
Literally anything which is a letter:
if ( $input =~ /[A-Za-z]/ ) {
print "Incorrect character detected!\n"
}

What does this script do in Perl? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can someone explain what the second half of this script does? (second line)
$self is defined elsewhere... (I know what that part does, Just wondering what the action=~... is all about/)
$action = "http://example.com/test.php";
$action = $self->{url} . ($action =~ /^\// ? "" : "/" ) . $action;
It returns an empty string if $action starts with a slash, and a slash if it does not start with a slash.

Converting single line to multiple lines in perl [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I have file as below.
ID || DATE || AMOUNT
XX||20130801##20130901##20131001##20131101||100##200##300##400
and I want the output as below using perl.
xx||20130801||100
xx||20130901||200
xx||20131001||300
xx||20131101||400
Please help me how to convert using perl.
perl -F'\|\||##' -lanE'$.>1 or $" ="||",next; say "#F[0,$_,$_+4]" for 1..4' file
perl -F'\|\|' -lane '#a=split(/##/,$F[1]); #b=split(/##/,$F[2]); print "$F[0]||$a[$_]||$b[$_]" foreach 0..$#a;' file
Output:
ID || DATE || AMOUNT
XX||20130801||100
XX||20130901||200
XX||20131001||300
XX||20131101||400

start condition for TeX equations [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
In lex, I can define the following starting condition for equations defined between $...$.
%x EQN1
\$ { BEGIN(EQN1); }
<EQN1>{
\$ { BEGIN(INITIAL); }
[^\$]* {}
}
For equations between $$...$$, how can I define the anything but $$ rule, such as in [^\$]*. I guess [^\$\$]* wouldn't work.
I think you don't understand the way the patterns are matched, see flex manual
Flex always try to match longest input possible. You can understand it in way, that longer rules have higher priority.
Because "\$\$" match two characters and "." just one, the example below will work just fine.
%x EQN2
\$\$ { BEGIN(EQN2); }
<EQN2>{
\$\$ { BEGIN(INITIAL); }
. {}
}
You can also replace [^\$]* {} with . {} in your example, because when rules match same size of input, the first one in lex.l has higher priority.