(CommandList children: [ (FuncDef name: usage body: (BraceGroup children: [ (Sentence child: (SimpleCommand words: [ {(echo)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(basename)} {($ VSub_Number '$0')})] ) left_token: <Left_CommandSub '$('> spids: [16 20] ) ( ' [-h] [-w <print-width>] -d <path> -f <x.y.z> -- upgrade syntax from version specified by -f to the latest version installed in the system\n' ) ('\n') ('where:\n') (' -h: show this text\n') (' -w <print-width=90>: change print-width of upgraded files\n') (' -d <path>: source code directory to be upgraded\n') (' -b <path>: path for backup directory\n') (' -f <x.y.z>: current version of the source file to be upgraded\n') (' ') ) } ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) terminator: <Op_Semi ';'> ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [11] ) spids: [7 10] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:REASON_GIT spids:[44]) op: Equal rhs: {(DQ ('git@github.com:facebook/Reason.git'))} spids: [44] ) ] spids: [44] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MERLINEXTEND_GIT spids:[49]) op: Equal rhs: {(DQ ('git@github.com:def-lkb/merlin-extend.git'))} spids: [49] ) ] spids: [49] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OPAM_BIN spids:[55]) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(opam)} {(config)} {(var)} {(bin)})]) left_token: <Left_CommandSub '$('> spids: [56 64] ) } spids: [55] ) ] spids: [55] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PRINTWIDTH spids:[67]) op:Equal rhs:{(90)} spids:[67])] spids: [67] ) (FuncDef name: install_refmt body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:VERSION spids:[78]) op: Equal rhs: {($ VSub_Number '$1')} spids: [78] ) ] spids: [78] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_f child: {($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION')} ) ) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} { (DQ (refmt-) ($ VSub_Name '$VERSION') (' already exists at ') ($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION') (', skipping installation') ) } ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(0)}) ] spids: [16777215 96] ) ] spids: [16777215 117] ) (C {(read)} {(-p)} { (DQ (refmt-) ($ VSub_Name '$VERSION') (' is needed but not found at ') ($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION') (', do you want me to install it? [Y/n]:') ) } {(-n)} {(1)} {(-r)} ) (If arms: [ (if_arm cond: [ (DBracket expr: (LogicalNot child: (BoolBinary op_id: BoolBinary_EqualTilde left: {($ VSub_Name '$REPLY')} right: {(Lit_Other '^') (Lit_Other '[') (Yy) (Lit_Other ']') (Lit_Other '$')} ) ) ) ] action: [(ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)})] spids: [16777215 160] ) ] spids: [16777215 168] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BUILD_DIR spids:[171]) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(mktemp)} {(-d)} {(-t)} {(reason_upgrade.XXXXXXXX)})] ) left_token: <Left_CommandSub '$('> spids: [172 180] ) } spids: [171] ) ] spids: [171] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OPAM_DIR spids:[183]) op: Equal rhs: {(DQ ($ VSub_Name '$BUILD_DIR') (/opam))} spids: [183] ) ] spids: [183] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:REASON_DIR spids:[190]) op: Equal rhs: {(DQ ($ VSub_Name '$BUILD_DIR') (/reason))} spids: [190] ) ] spids: [190] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:MERLINEXTEND_DIR spids:[197]) op: Equal rhs: {(DQ ($ VSub_Name '$BUILD_DIR') (/merlin-extend))} spids: [197] ) ] spids: [197] ) (C {(echo)} {(DQ ('Initing opam at ') ($ VSub_Name '$OPAM_DIR'))}) (C {(opam)} {(init)} {(--quiet)} {(-n)} {(--root)} {($ VSub_Name '$OPAM_DIR')}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark '$?')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ("Couldn't init opam at ") ($ VSub_Name '$OPAM_DIR') (', exiting'))} ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [16777215 238] ) ] spids: [16777215 259] ) (Sentence child: (C {(git)} {(clone)} {($ VSub_Name '$REASON_GIT')} {(--branch)} {($ VSub_Name '$VERSION')} {(--depth)} {(1)} {($ VSub_Name '$REASON_DIR')} ) terminator: <Op_Semi ';'> ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark '$?')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Couldn't clone reason from ") ($ VSub_Name '$REASON_GIT') (' to ') ($ VSub_Name '$REASON_DIR') (', exiting') ) } ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [16777215 293] ) ] spids: [16777215 316] ) (Sentence child: (C {(git)} {(clone)} {($ VSub_Name '$MERLINEXTEND_GIT')} {(--depth)} {(1)} {($ VSub_Name '$MERLINEXTEND_DIR')} ) terminator: <Op_Semi ';'> ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark '$?')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Couldn't clone merlin-extend from ") ($ VSub_Name '$MERLINEXTEND_GIT') (' to ') ($ VSub_Name '$MERLINEXTEND_DIR') (', exiting') ) } ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [16777215 347] ) ] spids: [16777215 370] ) (C {(opam)} {(pin)} {(add)} {($ VSub_Name '$MERLINEXTEND_DIR')} {(--root)} {($ VSub_Name '$OPAM_DIR')} {(-y)} ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark '$?')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ VSub_Name '$MERLINEXTEND_DIR') (' into ') ($ VSub_Name '$OPAM_DIR') ) } ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [16777215 401] ) ] spids: [16777215 423] ) (C {(opam)} {(pin)} {(add)} {($ VSub_Name '$REASON_DIR')} {(--root)} {($ VSub_Name '$OPAM_DIR')} {(-y)} ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id:BoolBinary_ne left:{($ VSub_QMark '$?')} right:{(0)}) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ VSub_Name '$REASON_DIR') (' into ') ($ VSub_Name '$OPAM_DIR') ) } ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (Sentence child: (ControlFlow token:<ControlFlow_Exit exit> arg_word:{(1)}) terminator: <Op_Semi ';'> ) ] spids: [16777215 455] ) ] spids: [16777215 477] ) (C {(echo)} { (DQ ('Installing refmt-') ($ VSub_Name '$VERSION') (' to OPAM_BIN/refmt-') ($ VSub_Name '$VERSION') ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OPAM_BIN_SANDBOX spids:[492]) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(opam)} {(config)} {(var)} {(bin)} {(--root)} {($ VSub_Name '$OPAM_DIR')}) ] ) left_token: <Left_CommandSub '$('> spids: [493 505] ) } spids: [492] ) ] spids: [492] ) (C {(cp)} {($ VSub_Name '$OPAM_BIN_SANDBOX') (/refmt)} {($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION')} ) (C {(echo)} {(DQ ('Removing sandbox ') ($ VSub_Name '$OPAM_BIN_SANDBOX'))}) (C {(rm)} {(-rf)} {($ VSub_Name '$OPAM_BIN_SANDBOX')}) ] spids: [75] ) spids: [71 74] ) (WhileUntil keyword: <KW_While while> cond: [ (Sentence child: (C {(getopts)} {(SQ <':hf:d:w:b:'>)} {(option)}) terminator: <Op_Semi ';'> ) ] body: (DoGroup children: [ (Case to_match: {(DQ ($ VSub_Name '$option'))} arms: [ (case_arm pat_list: [{(h)}] action: [(C {(usage)})] spids: [561 562 567 16777215] ) (case_arm pat_list: [{(d)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DIR spids:[573]) op: Equal rhs: {($ VSub_Name '$OPTARG')} spids: [573] ) ] spids: [573] ) ] spids: [570 571 577 16777215] ) (case_arm pat_list: [{(b)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BACKUP_DIR spids:[583]) op: Equal rhs: {($ VSub_Name '$OPTARG')} spids: [583] ) ] spids: [583] ) ] spids: [580 581 587 16777215] ) (case_arm pat_list: [{(f)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FROM spids:[593]) op: Equal rhs: {($ VSub_Name '$OPTARG')} spids: [593] ) ] spids: [593] ) ] spids: [590 591 597 16777215] ) (case_arm pat_list: [{(w)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PRINTWIDTH spids:[603]) op: Equal rhs: {($ VSub_Name '$OPTARG')} spids: [603] ) ] spids: [603] ) ] spids: [600 601 607 16777215] ) ] spids: [552 558 610] ) ] spids: [549 612] ) ) (C {(shift)} { (ArithSubPart anode: (ArithBinary op_id: Arith_Minus left: (ArithVarRef token:<Lit_ArithVarLike OPTIND>) right: (ArithWord w:{(Lit_Digits 1)}) ) spids: [616 623] ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$DIR')})) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ('No -d provided'))}] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] spids: [16777215 637] ) ] spids: [16777215 652] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DIR spids:[655]) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Sentence child: (C {(cd)} {(DQ ($ VSub_Name '$DIR'))}) terminator: <Op_Semi ';'> ) (C {(pwd)}) ] ) left_token: <Left_Backtick '`'> spids: [656 665] ) } spids: [655] ) ] spids: [655] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$FROM')})) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ('No -f <from_version> provided'))}] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] spids: [16777215 679] ) ] spids: [16777215 694] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (LogicalNot child: (BoolBinary op_id: BoolBinary_EqualTilde left: {($ VSub_Name '$FROM')} right: {(Lit_Other '^') (Lit_Other '(') (Lit_Other '[') (0-9) (Lit_Other ']') (EscapedLiteralPart token: <Lit_EscapedChar '\\.'> ) (Lit_Other '[') (0-9) (Lit_Other ']') (EscapedLiteralPart token:<Lit_EscapedChar '\\.'>) (Lit_Other '[') (0-9) (Lit_Other ']') (Lit_Other ')') (Lit_Other '$') } ) ) ) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [{(echo)} {(DQ ('version provided by -f should be in the form of x.y.z'))}] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] spids: [16777215 726] ) ] spids: [16777215 741] ) (C {(install_refmt)} {($ VSub_Name '$FROM')}) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_z child:{($ VSub_Name '$BACKUP_DIR')})) terminator: <Op_Semi ';'> ) ] action: [ (C {(echo)} {(DQ ('No -b <backup_dir> specified, default to use ') ($ VSub_Name '$DIR') (.backup))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:BACKUP_DIR spids:[772]) op: Equal rhs: {($ VSub_Name '$DIR') (.backup)} spids: [772] ) ] spids: [772] ) ] spids: [16777215 760] ) ] spids: [16777215 776] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr:(BoolUnary op_id:BoolUnary_d child:{($ VSub_Name '$BACKUP_DIR')})) terminator: <Op_Semi ';'> ) ] action: [ (SimpleCommand words: [ {(echo)} {(DQ ('Fail to backup: ') ($ VSub_Name '$BACKUP_DIR') (' already exists, exiting'))} ] redirects: [(Redir op:<Redir_GreatAnd '1>&'> fd:1 arg_word:{(2)})] ) (C {(usage)}) ] spids: [16777215 790] ) ] spids: [16777215 807] ) (C {(echo)} {(DQ ('Backing up at ') ($ VSub_Name '$BACKUP_DIR'))}) (C {(cp)} {(-af)} {($ VSub_Name '$DIR')} {($ VSub_Name '$BACKUP_DIR')}) (Pipeline children: [ (C {(find)} {($ VSub_Name '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.re'))}) (WhileUntil keyword: <KW_While while> cond: [(Sentence child:(C {(read)} {(file)}) terminator:<Op_Semi ';'>)] body: (DoGroup children: [ (C {(set)} {(-x)}) (Pipeline children: [ (C {($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION')} {(-print)} {(binary_reason)} {($ VSub_Name '$file')} ) (SimpleCommand words: [ {($ VSub_Name '$OPAM_BIN') (/refmt)} {(-print-width)} {($ VSub_Name '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-is-interface-pp)} {(false)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {($ VSub_Name '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ VSub_Name '$file') (.new)} {($ VSub_Name '$file')}) (C {(set)} {(Lit_Other '+') (x)}) ] spids: [849 913] ) ) ] negated: F ) (C {(set)} {(-x)}) (Pipeline children: [ (C {(find)} {($ VSub_Name '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.rei'))}) (WhileUntil keyword: <KW_While while> cond: [(Sentence child:(C {(read)} {(file)}) terminator:<Op_Semi ';'>)] body: (DoGroup children: [ (Pipeline children: [ (C {($ VSub_Name '$OPAM_BIN') (/refmt-) ($ VSub_Name '$VERSION')} {(-is-interface-pp)} {(true)} {(-print)} {(binary_reason)} {($ VSub_Name '$file')} ) (SimpleCommand words: [ {($ VSub_Name '$OPAM_BIN') (/refmt)} {(-is-interface-pp)} {(true)} {(-print-width)} {($ VSub_Name '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {($ VSub_Name '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ VSub_Name '$file') (.new)} {($ VSub_Name '$file')}) ] spids: [943 1000] ) ) ] negated: F ) (C {(set)} {(Lit_Other '+') (x)}) (C {(echo)} {(DQ ('Done. Original files are backed up at ') ($ VSub_Name '$BACKUP_DIR'))}) ] )