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