Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace egrep with grep -E #3485

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sync-doc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
TARGET=../../nextflow-website/assets
if egrep "^release = '.*edge|.*SNAPSHOT'$" -c conf.py >/dev/null; then
if grep -E "^release = '.*edge|.*SNAPSHOT'$" -c conf.py >/dev/null; then
MODE=edge
else
MODE=latest
Expand Down
2 changes: 1 addition & 1 deletion docs/tracing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ and many other metrics. You can see an example below:

.. note::
Nextflow collects these metrics through a background process for each job in the target environment.
Make sure the following tools are available in the environment where tasks are executed: ``awk``, ``date``, ``grep``, ``egrep``, ``ps``, ``sed``, ``tail``, ``tee``.
Make sure the following tools are available in the environment where tasks are executed: ``awk``, ``date``, ``grep``, ``ps``, ``sed``, ``tail``, ``tee``.
Moreover, some of these metrics are not reported when running on Mac OS X. See the note
about that in the `Trace report`_ below.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class UdockerBuilder extends ContainerBuilder<UdockerBuilder> {
@Override
String getRunCommand() {
def run = super.getRunCommand()
def result = "((udocker.py images | egrep -o \"^$image\\s\") || udocker.py pull \"$image\")>/dev/null\n"
def result = "((udocker.py images | grep -E -o \"^$image\\s\") || udocker.py pull \"$image\")>/dev/null\n"
result += "[[ \$? != 0 ]] && echo \"Udocker failed while pulling container \\`$image\\`\" >&2 && exit 1\n"
result += run
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class OarExecutor extends AbstractGridExecutor {
// see page 21 http://oar.imag.fr/docs/2.5/OAR-Documentation.pdf
String cmd = 'oarstat -f'
if( queue ) cmd += ' ' + queue
return ['sh','-c', "$cmd | egrep '(Job_Id:|state =)' ".toString()]
return ['sh','-c', "$cmd | grep -E '(Job_Id:|state =)' ".toString()]
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class PbsExecutor extends AbstractGridExecutor {
protected List<String> queueStatusCommand(Object queue) {
String cmd = 'qstat -f -1'
if( queue ) cmd += ' ' + queue
return ['bash','-c', "set -o pipefail; $cmd | { egrep '(Job Id:|job_state =)' || true; }".toString()]
return ['bash','-c', "set -o pipefail; $cmd | { grep -E '(Job Id:|job_state =)' || true; }".toString()]
}

static private Map DECODE_STATUS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class PbsProExecutor extends PbsExecutor {
if( queue ) {
cmd += queue
} else {
cmd += '$( qstat -B | egrep -v \'(^Server|^---)\' | awk -v ORS=\' \' \'{print \"@\"\$1}\' )'
cmd += '$( qstat -B | grep -E -v \'(^Server|^---)\' | awk -v ORS=\' \' \'{print \"@\"\$1}\' )'
}
return ['bash','-c', "set -o pipefail; $cmd | { egrep '(Job Id:|job_state =)' || true; }".toString()]
return ['bash','-c', "set -o pipefail; $cmd | { grep -E '(Job Id:|job_state =)' || true; }".toString()]
}

// see https://www.pbsworks.com/pdfs/PBSRefGuide18.2.pdf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ nxf_tree() {

pstat() {
local x_pid=$1
local STATUS=$(2> /dev/null < /proc/$1/status egrep 'Vm|ctxt')
local STATUS=$(2> /dev/null < /proc/$1/status grep -E 'Vm|ctxt')

if [ $? = 0 ]; then
local x_vsz=$(echo "$STATUS" | grep VmSize | awk '{print $2}' || echo -n '0')
local x_rss=$(echo "$STATUS" | grep VmRSS | awk '{print $2}' || echo -n '0')
local x_peak=$(echo "$STATUS" | egrep 'VmPeak|VmHWM' | sed 's/^.*:\s*//' | sed 's/[\sa-zA-Z]*$//' | tr '\n' ' ' || echo -n '0 0')
local x_peak=$(echo "$STATUS" | grep -E 'VmPeak|VmHWM' | sed 's/^.*:\s*//' | sed 's/[\sa-zA-Z]*$//' | tr '\n' ' ' || echo -n '0 0')
local x_pmem=$(awk -v rss=$x_rss -v mem_tot=$mem_tot 'BEGIN {printf "%.0f", rss/mem_tot*100*10}' || echo -n '0')
local vol_ctxt=$(echo "$STATUS" | grep '\bvoluntary_ctxt_switches' | awk '{print $2}' || echo -n '0')
local inv_ctxt=$(echo "$STATUS" | grep '\bnonvoluntary_ctxt_switches' | awk '{print $2}' || echo -n '0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class UdockerBuilderTest extends Specification {
def result = builder.build().getRunCommand()
then:
result == '''
((udocker.py images | egrep -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
((udocker.py images | grep -E -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
[[ $? != 0 ]] && echo "Udocker failed while pulling container \\`ubuntu:latest\\`" >&2 && exit 1
udocker.py run --rm -v "$PWD":"$PWD" -w "$PWD" --bindhome $(udocker.py create "ubuntu:latest")
'''
Expand All @@ -125,7 +125,7 @@ class UdockerBuilderTest extends Specification {
def result = builder.build().getRunCommand('bwa --this --that')
then:
result == '''
((udocker.py images | egrep -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
((udocker.py images | grep -E -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
[[ $? != 0 ]] && echo "Udocker failed while pulling container \\`ubuntu:latest\\`" >&2 && exit 1
udocker.py run --rm -v "$PWD":"$PWD" -w "$PWD" --bindhome $(udocker.py create "ubuntu:latest") bwa --this --that
'''
Expand All @@ -140,7 +140,7 @@ class UdockerBuilderTest extends Specification {
result = builder.build().getRunCommand('bwa --this --that')
then:
result == '''
((udocker.py images | egrep -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
((udocker.py images | grep -E -o "^ubuntu:latest\\s") || udocker.py pull "ubuntu:latest")>/dev/null
[[ $? != 0 ]] && echo "Udocker failed while pulling container \\`ubuntu:latest\\`" >&2 && exit 1
udocker.py run --rm -v "$PWD":"$PWD" -w "$PWD" --bindhome $(udocker.py create "ubuntu:latest") /bin/bash -c "bwa --this --that"
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ class OarExecutorTest extends Specification {
when:
def executor = [:] as OarExecutor
then:
executor.queueStatusCommand(null) == ['sh','-c', "oarstat -f | egrep '(Job_Id:|state =)' ".toString()]
executor.queueStatusCommand('xxx') == ['sh','-c', "oarstat -f xxx | egrep '(Job_Id:|state =)' ".toString()]
executor.queueStatusCommand(null) == ['sh','-c', "oarstat -f | grep -E '(Job_Id:|state =)' ".toString()]
executor.queueStatusCommand('xxx') == ['sh','-c', "oarstat -f xxx | grep -E '(Job_Id:|state =)' ".toString()]

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class PbsExecutorTest extends Specification {
def executor = [:] as PbsExecutor

expect:
executor.queueStatusCommand(null) == ['bash','-c', "set -o pipefail; qstat -f -1 | { egrep '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx') == ['bash','-c', "set -o pipefail; qstat -f -1 xxx | { egrep '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand(null) == ['bash','-c', "set -o pipefail; qstat -f -1 | { grep -E '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx') == ['bash','-c', "set -o pipefail; qstat -f -1 xxx | { grep -E '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx').each { assert it instanceof String }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class PbsProExecutorTest extends Specification {
def executor = [:] as PbsProExecutor

expect:
executor.queueStatusCommand(null) == ['bash','-c', "set -o pipefail; qstat -f \$( qstat -B | egrep -v '(^Server|^---)' | awk -v ORS=' ' '{print \"@\"\$1}' ) | { egrep '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx') == ['bash','-c', "set -o pipefail; qstat -f xxx | { egrep '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand(null) == ['bash','-c', "set -o pipefail; qstat -f \$( qstat -B | grep -E -v '(^Server|^---)' | awk -v ORS=' ' '{print \"@\"\$1}' ) | { grep -E '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx') == ['bash','-c', "set -o pipefail; qstat -f xxx | { grep -E '(Job Id:|job_state =)' || true; }"]
executor.queueStatusCommand('xxx').each { assert it instanceof String }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ nxf_tree() {

pstat() {
local x_pid=$1
local STATUS=$(2> /dev/null < /proc/$1/status egrep 'Vm|ctxt')
local STATUS=$(2> /dev/null < /proc/$1/status grep -E 'Vm|ctxt')

if [ $? = 0 ]; then
local x_vsz=$(echo "$STATUS" | grep VmSize | awk '{print $2}' || echo -n '0')
local x_rss=$(echo "$STATUS" | grep VmRSS | awk '{print $2}' || echo -n '0')
local x_peak=$(echo "$STATUS" | egrep 'VmPeak|VmHWM' | sed 's/^.*:\s*//' | sed 's/[\sa-zA-Z]*$//' | tr '\n' ' ' || echo -n '0 0')
local x_peak=$(echo "$STATUS" | grep -E 'VmPeak|VmHWM' | sed 's/^.*:\s*//' | sed 's/[\sa-zA-Z]*$//' | tr '\n' ' ' || echo -n '0 0')
local x_pmem=$(awk -v rss=$x_rss -v mem_tot=$mem_tot 'BEGIN {printf "%.0f", rss/mem_tot*100*10}' || echo -n '0')
local vol_ctxt=$(echo "$STATUS" | grep '\bvoluntary_ctxt_switches' | awk '{print $2}' || echo -n '0')
local inv_ctxt=$(echo "$STATUS" | grep '\bnonvoluntary_ctxt_switches' | awk '{print $2}' || echo -n '0')
Expand Down
4 changes: 2 additions & 2 deletions tests/checks/dynamic-storedir.nf/.checks
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rm my_*
echo ''
$NXF_RUN | tee stdout

[[ `grep 'INFO' .nextflow.log | egrep -c '\[skipping\] Stored process > foo'` == 4 ]] || false
[[ `grep 'INFO' .nextflow.log | grep -E -c '\[skipping\] Stored process > foo'` == 4 ]] || false

grep "Result $PWD/cache/omega/result.txt" stdout
grep "Result $PWD/cache/delta/result.txt" stdout
Expand All @@ -58,7 +58,7 @@ rm my_*
echo ''
$NXF_RUN -resume | tee stdout

[[ `grep 'INFO' .nextflow.log | egrep -c '\[skipping\] Stored process > foo'` == 4 ]] || false
[[ `grep 'INFO' .nextflow.log | grep -E -c '\[skipping\] Stored process > foo'` == 4 ]] || false

grep "Result $PWD/cache/omega/result.txt" stdout
grep "Result $PWD/cache/delta/result.txt" stdout
Expand Down
4 changes: 2 additions & 2 deletions tests/checks/error.nf/.checks
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $NXF_RUN -c .config | tee stdout
[[ `grep 'INFO' .nextflow.log | grep -c 'Submitted process > task1'` == 3 ]] || false
[[ `grep 'INFO' .nextflow.log | grep -c 'Submitted process > task2'` == 3 ]] || false

[[ `grep 'NOTE' .nextflow.log | egrep -c "Process .* terminated with an error exit status"` == 3 ]] || false
[[ `grep 'NOTE' .nextflow.log | grep -E -c "Process .* terminated with an error exit status"` == 3 ]] || false


#
Expand All @@ -20,4 +20,4 @@ $NXF_RUN -c .config -resume | tee stdout
[[ `grep 'INFO' .nextflow.log | grep -c 'Submitted process > task1'` == 3 ]] || false
[[ `grep 'INFO' .nextflow.log | grep -c 'Cached process > task2'` == 3 ]] || false

[[ `grep 'NOTE' .nextflow.log | egrep -c "Process .* terminated with an error exit status"` == 3 ]] || false
[[ `grep 'NOTE' .nextflow.log | grep -E -c "Process .* terminated with an error exit status"` == 3 ]] || false