Skip to content

Commit e0235c0

Browse files
committed
[infra] Discard output from the cd command when followed by pwd
This commits fixes the issue when `cd` is followed by the `pwd` in a bash one-liner which should get the directory in which the executed script is located. The problem with such approach is that the `cd` command can print the destination directory in case when one has the CDPATH environmental variable set. From the `man bash`: > cd [-L|...] [dir] > Change the current directory to dir. [...] If a non-empty directory > name from CDPATH is used the absolute pathname of the new working > directory is written to the standard output. ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy <a.bokowy@samsung.com>
1 parent d308930 commit e0235c0

23 files changed

+25
-25
lines changed

infra/packaging/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3+
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
44

55
if [[ -z "${NNAS_PROJECT_PATH}" ]]; then
66
echo "ERROR: NNAS_PROJECT_PATH is not specified"

infra/packaging/res/tf2nnpkg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20191215

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20200220

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20200508

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20200616

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20200630

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20210406

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20210706

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

infra/packaging/res/tf2nnpkg.20210910

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
66

77
command_exists() {
88
if [ "$#" -le 0 ]; then

0 commit comments

Comments
 (0)