[ 
https://issues.apache.org/jira/browse/NUTCH-3199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128147#comment-18128147
 ] 

ASF GitHub Bot commented on NUTCH-3199:
---------------------------------------

sebastian-nagel commented on code in PR #980:
URL: https://github.com/apache/nutch/pull/980#discussion_r4302611467


##########
src/bin/crawl:
##########
@@ -54,25 +54,28 @@
 ## @audience private
 ## @stability stable
 function __to_seconds() {
-  NUMBER=$(echo $1 | tr -dc '0-9')
-  MODIFIER=$(echo $1 | tr -dc '[^s|h|m|d]]')
+  NUMBER=$(printf '%s' "$1" | tr -dc '0-9')
+  # Same characters the previous tr expression kept: lowercase suffixes plus
+  # the literal brackets, caret, and pipe.
+  MODIFIER=$(printf '%s' "$1" | tr -dc '[]^dhms|')
 
   case $MODIFIER in
       m|M)
-        SECONDS=`expr $NUMBER \* 60`
+        SECONDS=$((10#$NUMBER * 60))
         ;;
       h|H)
-        SECONDS=`expr $NUMBER \* 120`
+        # h means 120 seconds here, not 3600. A follow-up issue tracks the 
correction.

Review Comment:
   Good catch! Not to forget about the follow-up issue!





> Yetus: harden bin/crawl and bin/nutch for remaining shellcheck findings
> -----------------------------------------------------------------------
>
>                 Key: NUTCH-3199
>                 URL: https://issues.apache.org/jira/browse/NUTCH-3199
>             Project: Nutch
>          Issue Type: Sub-task
>          Components: ci/cd
>            Reporter: Lewis John McGibbney
>            Assignee: Lewis John McGibbney
>            Priority: Major
>             Fix For: 1.24
>
>
> Even after errors are gone, shellcheck still reports on the order of 
> sixtywarnings and notes in the two driver scripts—mostly quoting, legacy 
> backticks, and related style that is easy to get wrong in a big bang rewrite.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to