Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fee15e

Browse files
committed
fix(stm32CubeProg): use BSD getopt for MacOS
On MacOS getopt is the BSD based one while otherusing the gnu-based getopt.Then "-o" and long options are not supportedFixes#99Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent354699b commit8fee15e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

‎stm32CubeProg.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -o nounset# Treat unset variables as an error
33
# set -o xtrace # Print command traces before executing command.
44

5+
UNAME_OS="$(uname -s)"
56
STM32CP_CLI=
67
INTERFACE=
78
PORT=
@@ -55,11 +56,21 @@ aborting() {
5556

5657
# parse command line arguments
5758
# options may be followed by one colon to indicate they have a required arg
58-
if! options=$(getopt -a -o hi:ef:o:c:r:d:v:p: --long help,interface:,erase,file:,offset:,com:,rts:,dtr:,vid:,pid: --"$@");then
59-
echo"Terminating...">&2
60-
exit 1
61-
fi
62-
59+
case"${UNAME_OS}"in
60+
Darwin*)
61+
echo"Warning: long options not supported due to getopt from FreeBSD usage."
62+
if! options=$(getopt hi:ef:o:c:r:d:v:p:"$@");then
63+
echo"Terminating...">&2
64+
exit 1
65+
fi
66+
;;
67+
*)
68+
if! options=$(getopt -a -o hi:ef:o:c:r:d:v:p: --long help,interface:,erase,file:,offset:,com:,rts:,dtr:,vid:,pid: --"$@");then
69+
echo"Terminating...">&2
70+
exit 1
71+
fi
72+
;;
73+
esac
6374
evalset --"$options"
6475

6576
whiletrue;do
@@ -109,10 +120,13 @@ while true; do
109120
shift
110121
break
111122
;;
123+
*)
124+
echo"Unknown option$1"
125+
usage 1
126+
;;
112127
esac
113128
done
114-
# Check STM32CubeProgrammer cli availability, fallback to dfu-util if protocol dfu
115-
UNAME_OS="$(uname -s)"
129+
# Check STM32CubeProgrammer cli availability
116130
case"${UNAME_OS}"in
117131
Linux*)
118132
STM32CP_CLI=STM32_Programmer.sh

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp