XComp commented on code in PR #683: URL: https://github.com/apache/flink-web/pull/683#discussion_r1368272121
########## _include/q/_utils.sh: ########## @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +CURRENT_DIR=`cd "$(dirname "$0")" && pwd -P` Review Comment: ```suggestion SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) ``` * `$0` doesn't work well with `source`. We would be on the save side to use `${BASH_SOURCE[0]}` instead. * nit: `$()` might be more future proof than using the legacy backticks * `$CURRENT_DIR` is ambiguous (it could be also the "current working directory"). `SCRIPT_DIR` sounds more specific here. WDYT? ########## _include/q/_utils.sh: ########## @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +CURRENT_DIR=`cd "$(dirname "$0")" && pwd -P` +CONFIG_DIR="${CURRENT_DIR}/../../docs/config.toml" + +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; Review Comment: > I validate the return value, but I don't know if I need to exit the shell script or print if there is no valid value. Test no valid value I feel like we should stick to `exit 1` here. The `return 1` might not be what we want when storing the function's return value in a variable: ```bash $ cat foo-utils.sh function foo() { return 1 } $ cat foo-main.sh source foo-utils.sh v=$(foo) echo "$v" ``` Calling `bash foo-main.sh` would lead to the call printing an empty line and exiting with 0. Considering that this is an error indicating some invalid state, we should fail the script fataly. WDYT? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
