@@ -6,7 +6,6 @@ CLAUDE_USER="${CLAUDE_USER:-claude}"
66CLAUDE_UID=" ${CLAUDE_UID:- 1001} "
77CLAUDE_GID=" ${CLAUDE_GID:- 1001} "
88CLAUDE_HOME=" ${CLAUDE_HOME:-/ home/ claude} "
9- USE_NONROOT=" ${USE_NONROOT:- false} "
109
1110show_environment_info () {
1211 echo " Claude Code YOLO Environment"
@@ -50,11 +49,7 @@ show_environment_info() {
5049 echo " Proxy configured"
5150 fi
5251
53- if [ " $USE_NONROOT " = " true" ]; then
54- echo " Non-root mode: $CLAUDE_USER (UID=$CLAUDE_UID , GID=$CLAUDE_GID )"
55- else
56- echo " Root mode: Running with --dangerously-skip-permissions"
57- fi
52+ echo " Running as: $CLAUDE_USER (UID=$CLAUDE_UID , GID=$CLAUDE_GID )"
5853
5954 echo " ================================"
6055}
@@ -208,72 +203,39 @@ main() {
208203 exit 1
209204 fi
210205
211- if [ " $USE_NONROOT " = " true " ] ; then
212- setup_nonroot_user
206+ # Always run as non-root claude user
207+ setup_nonroot_user
213208
214- if [ $# -eq 0 ]; then
215- echo " Starting Claude Code as $CLAUDE_USER with YOLO powers..."
216- build_gosu_env_cmd " $CLAUDE_USER " " $CLAUDE_CMD " --dangerously-skip-permissions
217- else
218- cmd=" $1 "
219- shift
220-
221- # Check if this is a Claude command (claude, claude-trace, etc.)
222- if [ " $cmd " = " claude" ] || [ " $cmd " = " $CLAUDE_CMD " ]; then
223- echo " Executing Claude as $CLAUDE_USER with YOLO powers: $cmd $@ "
224- build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ " --dangerously-skip-permissions
225- elif [ " $cmd " = " claude-trace" ]; then
226- echo " Executing Claude-trace as $CLAUDE_USER with YOLO powers: $cmd $@ "
227- # claude-trace --include-all-requests --run-with claude [args]
228- # We need to inject --dangerously-skip-permissions into the claude command
229- args=(" $@ " )
230- new_args=()
231- i=0
232- while [ $i -lt ${# args[@]} ]; do
233- if [ " ${args[$i]} " = " --run-with" ] && [ $(( i + 1 )) -lt ${# args[@]} ] && [ " ${args[$((i + 1))]} " = " claude" ]; then
234- new_args+=(" --run-with" " claude" " --dangerously-skip-permissions" )
235- i=$(( i + 2 ))
236- else
237- new_args+=(" ${args[$i]} " )
238- i=$(( i + 1 ))
239- fi
240- done
241- build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " ${new_args[@]} "
242- else
243- echo " Executing as $CLAUDE_USER : $cmd $@ "
244- build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ "
245- fi
246- fi
209+ if [ $# -eq 0 ]; then
210+ echo " Starting Claude Code as $CLAUDE_USER with YOLO powers..."
211+ build_gosu_env_cmd " $CLAUDE_USER " " $CLAUDE_CMD " --dangerously-skip-permissions
247212 else
248- if [ $# -eq 0 ]; then
249- echo " Starting Claude Code in root mode with YOLO powers..."
250- exec " $CLAUDE_CMD " --dangerously-skip-permissions
213+ cmd=" $1 "
214+ shift
215+
216+ # Check if this is a Claude command (claude, claude-trace, etc.)
217+ if [ " $cmd " = " claude" ] || [ " $cmd " = " $CLAUDE_CMD " ]; then
218+ echo " Executing Claude as $CLAUDE_USER with YOLO powers: $cmd $@ "
219+ build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ " --dangerously-skip-permissions
220+ elif [ " $cmd " = " claude-trace" ]; then
221+ echo " Executing Claude-trace as $CLAUDE_USER with YOLO powers: $cmd $@ "
222+ # claude-trace --include-all-requests --run-with [args]
223+ # We need to inject --dangerously-skip-permissions as first argument after --run-with
224+ args=(" $@ " )
225+ new_args=()
226+ i=0
227+ while [ $i -lt ${# args[@]} ]; do
228+ if [ " ${args[$i]} " = " --run-with" ]; then
229+ new_args+=(" --run-with" " --dangerously-skip-permissions" )
230+ else
231+ new_args+=(" ${args[$i]} " )
232+ fi
233+ i=$(( i + 1 ))
234+ done
235+ build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " ${new_args[@]} "
251236 else
252- cmd=" $1 "
253- if [ " $cmd " = " claude" ] || [ " $cmd " = " $CLAUDE_CMD " ]; then
254- echo " Executing Claude in root mode with YOLO powers: $@ "
255- exec " $@ " --dangerously-skip-permissions
256- elif [ " $cmd " = " claude-trace" ]; then
257- echo " Executing Claude-trace in root mode with YOLO powers: $@ "
258- # claude-trace --include-all-requests --run-with claude [args]
259- # We need to inject --dangerously-skip-permissions into the claude command
260- args=(" $@ " )
261- new_args=()
262- i=1 # Skip first arg (claude-trace)
263- while [ $i -lt ${# args[@]} ]; do
264- if [ " ${args[$i]} " = " --run-with" ] && [ $(( i + 1 )) -lt ${# args[@]} ] && [ " ${args[$((i + 1))]} " = " claude" ]; then
265- new_args+=(" --run-with" " claude" " --dangerously-skip-permissions" )
266- i=$(( i + 2 ))
267- else
268- new_args+=(" ${args[$i]} " )
269- i=$(( i + 1 ))
270- fi
271- done
272- exec " $cmd " " ${new_args[@]} "
273- else
274- echo " Executing: $@ "
275- exec " $@ "
276- fi
237+ echo " Executing as $CLAUDE_USER : $cmd $@ "
238+ build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ "
277239 fi
278240 fi
279241}
0 commit comments