#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # Usage: very similar to `install` # install.sh 755 src1 src2 ... dest global PERMS := $1 shift global ARGS := ''"" while [ $# -gt 1 ] { global ARGS := ""$ARGS $1"" shift } global DEST := $1 for SRC in [$ARGS] { cp -a $SRC $DEST if test -d $DEST { global DESTFILE := ""$DEST/$[basename $SRC]"" } else { global DESTFILE := $DEST } # Do the chmod dance, and ignore errors on platforms that don't like setting permissions of symlinks # TODO: Test if it's a symlink instead of having to redirect stderr to /dev/null chmod $PERMS $DESTFILE !2 >/dev/null } exit 0 (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PERMS) op:Equal rhs:{($ VSub_Number "$1")} spids:[14])] spids: [14] ) (C {(shift)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:ARGS) op:Equal rhs:{(DQ )} spids:[20])] spids: [20] ) (While cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Pound "$#")} {(-gt)} {(1)} {(Lit_Other "]")}) terminator: ) ] body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ARGS) op: Equal rhs: {(DQ ($ VSub_Name "$ARGS") (" ") ($ VSub_Number "$1"))} spids: [40] ) ] spids: [40] ) (C {(shift)}) ] spids: [37 50] ) ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:DEST) op:Equal rhs:{($ VSub_Number "$1")} spids:[52])] spids: [52] ) (ForEach iter_name: SRC iter_words: [{($ VSub_Name "$ARGS")}] do_arg_iter: False body: (DoGroup children: [ (C {(cp)} {(-a)} {($ VSub_Name "$SRC")} {($ VSub_Name "$DEST")}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-d)} {(DQ ($ VSub_Name "$DEST"))} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DESTFILE) op: Equal rhs: { (DQ ($ VSub_Name "$DEST") (/) (CommandSubPart command_list: (CommandList children: [(C {(basename)} {(DQ ($ VSub_Name "$SRC"))})] ) left_token: spids: [98 104] ) ) } spids: [94] ) ] spids: [94] ) ] spids: [-1 91] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DESTFILE) op: Equal rhs: {(DQ ($ VSub_Name "$DEST"))} spids: [111] ) ] spids: [111] ) ] spids: [108 117] ) (SimpleCommand words: [{(chmod)} {($ VSub_Name "$PERMS")} {($ VSub_Name "$DESTFILE")}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[135])] ) ] spids: [65 138] ) spids: [61 63] ) (C {(exit)} {(0)}) ] )