(command.CommandList children: [ (command.ShFunction name: usage body: (command.BraceGroup children: [ (command.Sentence child: (command.Simple words: [ {(echo)} { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:16) command_list: (command.CommandList children: [(C {(basename)} {($ Id.VSub_Number '$0')})] ) ) ( ' [-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: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:32) fd: 1 arg_word: {(2)} ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:34) ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:36) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:39) ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:REASON_GIT) op: assign_op.Equal rhs: {(DQ ('git@github.com:facebook/Reason.git'))} spids: [44] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:MERLINEXTEND_GIT) op: assign_op.Equal rhs: {(DQ ('git@github.com:def-lkb/merlin-extend.git'))} spids: [49] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_BIN) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:56) command_list: (command.CommandList children: [(C {(opam)} {(config)} {(Id.KW_Var var)} {(bin)})] ) ) } spids: [55] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PRINTWIDTH) op: assign_op.Equal rhs: {(90)} spids: [67] ) ] ) (command.ShFunction name: install_refmt body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:VERSION) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [78] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_f child: {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.VSub_DollarName '$VERSION') } ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:93) ) ] action: [ (C {(echo)} { (DQ (refmt-) ($ Id.VSub_DollarName '$VERSION') (' already exists at ') ($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.VSub_DollarName '$VERSION') (', skipping installation') ) } ) (command.ControlFlow token: (Token id:Id.ControlFlow_Return val:return span_id:112) arg_word: {(0)} ) ] spids: [82 96] ) ] ) (C {(read)} {(-p)} { (DQ (refmt-) ($ Id.VSub_DollarName '$VERSION') (' is needed but not found at ') ($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.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.Binary op_id: Id.BoolBinary_EqualTilde left: {($ Id.VSub_DollarName '$REPLY')} right: {(Id.Lit_Other '^') (Id.Lit_Other '[') (Yy) (Id.Lit_Other ']') (Id.Lit_Other '$') } ) ) ) ] action: [ (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:163) arg_word: {(1)} ) ] spids: [141 160] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BUILD_DIR) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:172) command_list: (command.CommandList children: [(C {(mktemp)} {(-d)} {(-t)} {(reason_upgrade.XXXXXXXX)})] ) ) } spids: [171] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') (/opam))} spids: [183] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:REASON_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') (/reason))} spids: [190] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:MERLINEXTEND_DIR) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$BUILD_DIR') (/merlin-extend))} spids: [197] ) ] ) (C {(echo)} {(DQ ('Initing opam at ') ($ Id.VSub_DollarName '$OPAM_DIR'))}) (C {(opam)} {(init)} {(--quiet)} {(-n)} {(--root)} {($ Id.VSub_DollarName '$OPAM_DIR')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:236) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't init opam at ") ($ Id.VSub_DollarName '$OPAM_DIR') (', exiting') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:249) fd: 1 arg_word: {(2)} ) ] ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:253) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:256) ) ] spids: [225 238] ) ] ) (command.Sentence child: (C {(git)} {(clone)} {($ Id.VSub_DollarName '$REASON_GIT')} {(--branch)} {($ Id.VSub_DollarName '$VERSION')} {(--depth)} {(1)} {($ Id.VSub_DollarName '$REASON_DIR')} ) terminator: (Token id:Id.Op_Semi val:';' span_id:277) ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:291) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't clone reason from ") ($ Id.VSub_DollarName '$REASON_GIT') (' to ') ($ Id.VSub_DollarName '$REASON_DIR') (', exiting') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:306) fd: 1 arg_word: {(2)} ) ] ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:310) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:313) ) ] spids: [280 293] ) ] ) (command.Sentence child: (C {(git)} {(clone)} {($ Id.VSub_DollarName '$MERLINEXTEND_GIT')} {(--depth)} {(1)} {($ Id.VSub_DollarName '$MERLINEXTEND_DIR')} ) terminator: (Token id:Id.Op_Semi val:';' span_id:331) ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:345) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't clone merlin-extend from ") ($ Id.VSub_DollarName '$MERLINEXTEND_GIT') (' to ') ($ Id.VSub_DollarName '$MERLINEXTEND_DIR') (', exiting') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:360) fd: 1 arg_word: {(2)} ) ] ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:364) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:367) ) ] spids: [334 347] ) ] ) (C {(opam)} {(pin)} {(add)} {($ Id.VSub_DollarName '$MERLINEXTEND_DIR')} {(--root)} {($ Id.VSub_DollarName '$OPAM_DIR')} {(-y)} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:399) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ Id.VSub_DollarName '$MERLINEXTEND_DIR') (' into ') ($ Id.VSub_DollarName '$OPAM_DIR') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:413) fd: 1 arg_word: {(2)} ) ] ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:417) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:420) ) ] spids: [388 401] ) ] ) (C {(opam)} {(pin)} {(add)} {($ Id.VSub_DollarName '$REASON_DIR')} {(--root)} {($ Id.VSub_DollarName '$OPAM_DIR')} {(-y)} ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Binary op_id: Id.BoolBinary_ne left: {($ Id.VSub_QMark '$?')} right: {(0)} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:453) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ("Couldn't opam pin ") ($ Id.VSub_DollarName '$REASON_DIR') (' into ') ($ Id.VSub_DollarName '$OPAM_DIR') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:467) fd: 1 arg_word: {(2)} ) ] ) (command.Sentence child: (command.ControlFlow token: (Token id:Id.ControlFlow_Exit val:exit span_id:471) arg_word: {(1)} ) terminator: (Token id:Id.Op_Semi val:';' span_id:474) ) ] spids: [442 455] ) ] ) (C {(echo)} { (DQ ('Installing refmt-') ($ Id.VSub_DollarName '$VERSION') (' to OPAM_BIN/refmt-') ($ Id.VSub_DollarName '$VERSION') ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:OPAM_BIN_SANDBOX) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:493) command_list: (command.CommandList children: [ (C {(opam)} {(config)} {(Id.KW_Var var)} {(bin)} {(--root)} {($ Id.VSub_DollarName '$OPAM_DIR')} ) ] ) ) } spids: [492] ) ] ) (C {(cp)} {($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX') (/refmt)} {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.VSub_DollarName '$VERSION')} ) (C {(echo)} {(DQ ('Removing sandbox ') ($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX'))}) (C {(rm)} {(-rf)} {($ Id.VSub_DollarName '$OPAM_BIN_SANDBOX')}) ] ) ) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:538) cond: [ (command.Sentence child: (C {(getopts)} {(SQ (Token id:Id.Lit_Chars val:':hf:d:w:b:' span_id:543))} {(option)}) terminator: (Token id:Id.Op_Semi val:';' span_id:547) ) ] body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$option'))} arms: [ (case_arm pat_list: [{(h)}] action: [(C {(usage)})] spids: [561 562 567 -1] ) (case_arm pat_list: [{(d)}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [573] ) ] ) ] spids: [570 571 577 -1] ) (case_arm pat_list: [{(b)}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BACKUP_DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [583] ) ] ) ] spids: [580 581 587 -1] ) (case_arm pat_list: [{(f)}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FROM) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [593] ) ] ) ] spids: [590 591 597 -1] ) (case_arm pat_list: [{(w)}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PRINTWIDTH) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$OPTARG')} spids: [603] ) ] ) ] spids: [600 601 607 -1] ) ] ) ] ) ) (C {(shift)} { (word_part.ArithSub anode: (arith_expr.Binary op_id: Id.Arith_Minus left: (arith_expr.VarRef token:(Token id:Id.Lit_ArithVarLike val:OPTIND span_id:617)) right: (arith_expr.ArithWord w:{(Id.Lit_Digits 1)}) ) ) } ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:Id.BoolUnary_z child:{($ Id.VSub_DollarName '$DIR')}) ) terminator: (Token id:Id.Op_Semi val:';' span_id:635) ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('No -d provided'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:646) fd: 1 arg_word: {(2)} ) ] ) (C {(usage)}) ] spids: [626 637] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:DIR) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_Backtick val:'`' span_id:656) command_list: (command.CommandList children: [ (command.Sentence child: (C {(cd)} {(DQ ($ Id.VSub_DollarName '$DIR'))}) terminator: (Token id:Id.Op_Semi val:';' span_id:664) ) (C {(pwd)}) ] ) ) } spids: [655] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id:Id.BoolUnary_z child:{($ Id.VSub_DollarName '$FROM')}) ) terminator: (Token id:Id.Op_Semi val:';' span_id:679) ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('No -f <from_version> provided'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:690) fd: 1 arg_word: {(2)} ) ] ) (C {(usage)}) ] spids: [670 681] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.LogicalNot child: (bool_expr.Binary op_id: Id.BoolBinary_EqualTilde left: {($ Id.VSub_DollarName '$FROM')} right: {(Id.Lit_Other '^') (Id.Lit_Other '(') (Id.Lit_Other '[') (0-9) (Id.Lit_Other ']') (Id.Lit_RegexMeta '\\.') (Id.Lit_Other '[') (0-9) (Id.Lit_Other ']') (Id.Lit_RegexMeta '\\.') (Id.Lit_Other '[') (0-9) (Id.Lit_Other ']') (Id.Lit_Other ')') (Id.Lit_Other '$') } ) ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:726) ) ] action: [ (command.Simple words: [{(echo)} {(DQ ('version provided by -f should be in the form of x.y.z'))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:737) fd: 1 arg_word: {(2)} ) ] ) (C {(usage)}) ] spids: [699 728] ) ] ) (C {(install_refmt)} {($ Id.VSub_DollarName '$FROM')}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_z child: {($ Id.VSub_DollarName '$BACKUP_DIR')} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:760) ) ] action: [ (C {(echo)} { (DQ ('No -b <backup_dir> specified, default to use ') ($ Id.VSub_DollarName '$DIR') (.backup) ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:BACKUP_DIR) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$DIR') (.backup)} spids: [774] ) ] ) ] spids: [751 762] ) ] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.DBracket expr: (bool_expr.Unary op_id: Id.BoolUnary_d child: {($ Id.VSub_DollarName '$BACKUP_DIR')} ) ) terminator: (Token id:Id.Op_Semi val:';' span_id:790) ) ] action: [ (command.Simple words: [ {(echo)} { (DQ ('Fail to backup: ') ($ Id.VSub_DollarName '$BACKUP_DIR') (' already exists, exiting') ) } ] redirects: [ (redir.Redir op: (Token id:Id.Redir_GreatAnd val:'1>&' span_id:803) fd: 1 arg_word: {(2)} ) ] ) (C {(usage)}) ] spids: [781 792] ) ] ) (C {(echo)} {(DQ ('Backing up at ') ($ Id.VSub_DollarName '$BACKUP_DIR'))}) (C {(cp)} {(-af)} {($ Id.VSub_DollarName '$DIR')} {($ Id.VSub_DollarName '$BACKUP_DIR')}) (command.Pipeline children: [ (C {(find)} {($ Id.VSub_DollarName '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.re'))}) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:844) cond: [ (command.Sentence child: (C {(read)} {(file)}) terminator: (Token id:Id.Op_Semi val:';' span_id:849) ) ] body: (command.DoGroup children: [ (C {(Id.KW_Set set)} {(-x)}) (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.VSub_DollarName '$VERSION')} {(-print)} {(binary_reason)} {($ Id.VSub_DollarName '$file')} ) (command.Simple words: [ {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt)} {(-print-width)} {($ Id.VSub_DollarName '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-is-interface-pp)} {(false)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:894) fd: -1 arg_word: {($ Id.VSub_DollarName '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ Id.VSub_DollarName '$file') (.new)} {($ Id.VSub_DollarName '$file')}) (C {(Id.KW_Set set)} {(Id.Lit_Other '+') (x)}) ] ) ) ] negated: F ) (C {(Id.KW_Set set)} {(-x)}) (command.Pipeline children: [ (C {(find)} {($ Id.VSub_DollarName '$DIR')} {(-type)} {(f)} {(-name)} {(DQ ('*.rei'))}) (command.WhileUntil keyword: (Token id:Id.KW_While val:while span_id:938) cond: [ (command.Sentence child: (C {(read)} {(file)}) terminator: (Token id:Id.Op_Semi val:';' span_id:943) ) ] body: (command.DoGroup children: [ (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt-) ($ Id.VSub_DollarName '$VERSION')} {(-is-interface-pp)} {(true)} {(-print)} {(binary_reason)} {($ Id.VSub_DollarName '$file')} ) (command.Simple words: [ {($ Id.VSub_DollarName '$OPAM_BIN') (/refmt)} {(-is-interface-pp)} {(true)} {(-print-width)} {($ Id.VSub_DollarName '$PRINTWIDTH')} {(-use-stdin)} {(true)} {(-parse)} {(binary_reason)} {(-print)} {(re)} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:987) fd: -1 arg_word: {($ Id.VSub_DollarName '$file') (.new)} ) ] ) ] negated: F ) (C {(mv)} {(-f)} {($ Id.VSub_DollarName '$file') (.new)} {($ Id.VSub_DollarName '$file')}) ] ) ) ] negated: F ) (C {(Id.KW_Set set)} {(Id.Lit_Other '+') (x)}) (C {(echo)} {(DQ ('Done. Original files are backed up at ') ($ Id.VSub_DollarName '$BACKUP_DIR'))}) ] )