@@ -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,82 +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 [args]
228- # We need to inject --dangerously-skip-permissions into the claude arguments
229- args=(" $@ " )
230- new_args=()
231- i=0
232- inject_next=false
233- while [ $i -lt ${# args[@]} ]; do
234- if [ " ${args[$i]} " = " --run-with" ]; then
235- new_args+=(" --run-with" )
236- inject_next=true
237- elif [ " $inject_next " = true ]; then
238- # First argument after --run-with gets --dangerously-skip-permissions added
239- new_args+=(" ${args[$i]} " " --dangerously-skip-permissions" )
240- inject_next=false
241- else
242- new_args+=(" ${args[$i]} " )
243- fi
244- i=$(( i + 1 ))
245- done
246- build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " ${new_args[@]} "
247- else
248- echo " Executing as $CLAUDE_USER : $cmd $@ "
249- build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ "
250- fi
251- 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
252212 else
253- if [ $# -eq 0 ]; then
254- echo " Starting Claude Code in root mode with YOLO powers..."
255- 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[@]} "
256236 else
257- cmd=" $1 "
258- if [ " $cmd " = " claude" ] || [ " $cmd " = " $CLAUDE_CMD " ]; then
259- echo " Executing Claude in root mode with YOLO powers: $@ "
260- exec " $@ " --dangerously-skip-permissions
261- elif [ " $cmd " = " claude-trace" ]; then
262- echo " Executing Claude-trace in root mode with YOLO powers: $@ "
263- # claude-trace --include-all-requests --run-with [args]
264- # We need to inject --dangerously-skip-permissions into the claude arguments
265- args=(" $@ " )
266- new_args=()
267- i=1 # Skip first arg (claude-trace)
268- inject_next=false
269- while [ $i -lt ${# args[@]} ]; do
270- if [ " ${args[$i]} " = " --run-with" ]; then
271- new_args+=(" --run-with" )
272- inject_next=true
273- elif [ " $inject_next " = true ]; then
274- # First argument after --run-with gets --dangerously-skip-permissions added
275- new_args+=(" ${args[$i]} " " --dangerously-skip-permissions" )
276- inject_next=false
277- else
278- new_args+=(" ${args[$i]} " )
279- fi
280- i=$(( i + 1 ))
281- done
282- exec " $cmd " " ${new_args[@]} "
283- else
284- echo " Executing: $@ "
285- exec " $@ "
286- fi
237+ echo " Executing as $CLAUDE_USER : $cmd $@ "
238+ build_gosu_env_cmd " $CLAUDE_USER " " $cmd " " $@ "
287239 fi
288240 fi
289241}
0 commit comments