Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6b9ec238a7
Fetching contributors…

Cannot retrieve contributors at this time

executable file 751 lines (579 sloc) 18.489 kb
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>#64854: [PATCH] added chdir and $*CWD</title>
<link rel="shortcut icon" href="/rt3/NoAuth/images//favicon.png" type="image/png" />
<link rel="stylesheet" href="/rt3/NoAuth/css/rt.perl.org/main.css" type="text/css" media="all" />
<link rel="stylesheet" href="/rt3/NoAuth/css/print.css" type="text/css" media="print" />
<script type="text/javascript" src="/rt3/NoAuth/js/util.js"></script>
<script type="text/javascript" src="/rt3/NoAuth/js/titlebox-state.js"></script>
<script type="text/javascript"><!--
onLoadHook("loadTitleBoxStates()");
--></script>
</head>
<body id="comp-Public-Bug-Display">
<div id="logo">
<a href="http://rt.perl.org/rt3/"><img src="/rt3/NoAuth/images//local/pblogo.gif" alt="PerlBug" width="230" height="50"></a>
</div>
<div id="quickbar">
<div id="quick-personal">
<span class="hide"><a href="#skipnav">Skip Menu</a> | </span>
You are currently an anonymous guest.
|
<a href="/rt3/NoAuth/Logout.html?URL=/rt3/index.html?goto=%252FPublic%252FBug%252FDisplay.html%253Fid%253D64854">Login</a>
|
<a href="/rt3/NoAuth/Logout.html">Return to Main</a>
| <a href="/rt3/User/Prefs.html">Preferences</a>
</div>
<div id="topactions">
<span class="topaction">
<form action="/rt3/Public/Search/Simple.html">
<input size="12" name="q" autocomplete="off" accesskey="0" class="field" />
<input type="submit" class="button" value="Search" />
</form>
</span>
</div>
</div>
<div id="nav">
<ul id="system-menu">
<div><div class="wrapper">
</div></div>
</ul>
</div>
<div id="header">
<h1>#64854: [PATCH] added chdir and $*CWD</h1>
<ul id="page-menu">
<div><div><div>
&nbsp;
</div></div></div>
</ul>
</div>
<div id="body">
<a name="skipnav" id="skipnav" accesskey="8"></a>
<div class="">
<div class="titlebox " id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html------Report information---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left">Report information</span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html------Report information---0">
<table width="100%" class="ticket-summary">
<tr>
<td valign="top" width="50%" class="boxcontainer">
<div class="ticket-info-basics">
<div class="titlebox ticket-info-basics" id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html--ticket-info-basics----The Basics---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left"><a href="/rt3/Ticket/Modify.html?id=64854">The Basics</a></span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html--ticket-info-basics----The Basics---0">
<table>
<tr>
<td class="label id">Id:</td>
<td class="value id">64854</td>
</tr>
<tr>
<td class="label status">Status:</td>
<td class="value status">resolved</td>
</tr>
<tr>
<td class="label time left">Left:</td>
<td class="value time left">0 min
</td>
</tr>
<tr>
<td class="label priority">Priority:</td>
<td class="value priority">0/0</td>
</tr>
<tr>
<td class="label queue">Queue:</td>
<td class="value queue">perl6
</td>
</tr>
</table>
<hr class="clear" />
</div>
</div>
</div>
<div class="ticket-info-people">
<div class="titlebox ticket-info-people" id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html--ticket-info-people----People---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left"><a href="/rt3/Ticket/ModifyPeople.html?id=64854">People</a></span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html--ticket-info-people----People---0">
<table>
<tr>
<td class="label">Owner:</td>
<td class="value">
Nobody
</td>
</tr>
<tr>
<td class="labeltop">Requestors:</td>
<td class="value">
cosmicnetworks
&lt;webmaster [at] cosmicperl.com&gt;
<br />
</td>
</tr>
<tr>
<td class="labeltop">Cc:</td>
<td class="value">
</td>
</tr>
<tr>
<td class="labeltop">AdminCc:</td>
<td class="value">
</td>
</tr>
</table>
<hr class="clear" />
</div>
</div>
</div>
</td>
<td valign="top" width="50%" class="boxcontainer">
<div class="ticket-info-cfs">
<div class="titlebox ticket-info-cfs" id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html--ticket-info-cfs----Bug Information---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left"><a href="/rt3/Ticket/Modify.html?id=64854">Bug Information</a></span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html--ticket-info-cfs----Bug Information---0">
<table>
<tr id="CF-18-ShowRow">
<td class="label">Severity:</td>
<td class="value">
<i>(no value)</i>
</td>
</tr>
<tr id="CF-19-ShowRow">
<td class="label">Tag:</td>
<td class="value">
Patch </td>
</tr>
<tr id="CF-20-ShowRow">
<td class="label">Platform:</td>
<td class="value">
<i>(no value)</i>
</td>
</tr>
<tr id="CF-21-ShowRow">
<td class="label">Patch Status:</td>
<td class="value">
<i>(no value)</i>
</td>
</tr>
</table>
<hr class="clear" />
</div>
</div>
</div>
<div class="ticket-info-links">
<div class="titlebox ticket-info-links" id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html--ticket-info-links----Links---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left"><a href="/rt3/Ticket/ModifyLinks.html?id=64854">Links</a></span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html--ticket-info-links----Links---0">
<table>
<tr>
<td class="labeltop">Depends on:</td>
<td class="value">
<ul>
</ul>
</td>
</tr>
<tr>
<td class="labeltop">Depended on by:</td>
<td class="value">
<ul>
</ul>
</td>
</tr>
<tr>
<td class="labeltop">Parents:</td>
<td class="value">
<ul>
</ul>
</td>
</tr>
<tr>
<td class="labeltop">Children:</td>
<td class="value"></td>
</tr>
<tr>
<td class="labeltop">Refers to:</td>
<td class="value">
<ul>
</ul>
</td>
</tr>
<tr>
<td class="labeltop">Referred to by:</td>
<td class="value">
<ul>
</ul>
</td>
</tr>
</table>
<hr class="clear" />
</div>
</div>
</div>
<div class="">
<div class="titlebox " id="">
<div class="titlebox-title inverse">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html------Attachments---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left">Attachments</span>
<span class="right"></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html------Attachments---0">
0001-added-chdir-and-CWD.patch<br />
<ul>
<li><font size="-2">
<a href="/rt3/Ticket/Attachment/553848/263412/0001-added-chdir-and-CWD.patch">
Sun Apr 19 10:11:22 2009 (2k) by cosmicnetworks
</a>
</font></li>
</ul>
<hr class="clear" />
</div>
</div>
</div>
<br />
</td>
</tr>
</table>
<hr class="clear" />
</div>
</div>
</div>
<br />
<div class="titlebox " id="">
<div class="titlebox-title">
<span class="widget"><a href="#" onclick="return rollup('TitleBox--_Public_Bug_Display.html------History---0');" onfocus="this.blur(); return false;" title="Toggle visibility">X</a></span>
<span class="left">History</span>
<span class="right"><span style="color: black">Display mode:</span> <span class="selected">Brief headers</span> &mdash; <a href="/rt3/Ticket/Display.html?ShowHeaders=1;id=64854">Full headers</a></span>
</div>
<div class="titlebox-content " id="TitleBox--_Public_Bug_Display.html------History---0">
<div id="ticket-history">
<div class="ticket-transaction message odd">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td rowspan="2" valign="top" class="type">
<a name="txn-553848" href="/rt3/Ticket/Display.html?id=64854#txn-553848">#</a>
&nbsp;
</td>
<td class="date">Sun&nbsp;Apr&nbsp;19&nbsp;10:11:22&nbsp;2009</td>
<td class="description">
cosmicnetworks - Ticket created
</td>
<td class="time-taken"></td>
<td class="actions">&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="content">
<table>
<tr>
<td align="right" class="message-header-key">Subject:</td>
<td class="message-header-value">[PATCH] added chdir and $*CWD</td>
</tr>
<tr>
<td align="right" class="message-header-key">Date:</td>
<td class="message-header-value">Sun, 19 Apr 2009 18:10:33 +0100</td>
</tr>
<tr>
<td align="right" class="message-header-key">To:</td>
<td class="message-header-value">rakudobug <!-- x --> at perl.org</td>
</tr>
<tr>
<td align="right" class="message-header-key">From:</td>
<td class="message-header-value">Lyle &lt;webmaster <!-- x --> at cosmicperl.com&gt;</td>
</tr>
</table>
<div class="messagebody">
<table>
</table>
<div class="downloadattachment">
<a href="/rt3/Ticket/Attachment/553848/263410/">Download &#40;untitled&#41;</a>
<span class="downloadcontenttype">
[text/plain 145b]
</span>
</div>
<div class="messagebody">
<div class="message-stanza-depth-0">
Hi,<br />
Please find the patch attached. Let me know if you have any questions.<br />
<br />
I&#39;ve tested this code against the chdir and cwd spec tests.<br />
<br />
<br />
Lyle<br />
</div>
</div>
<table>
</table>
<div class="downloadattachment">
<a href="/rt3/Ticket/Attachment/553848/263412/0001-added-chdir-and-CWD.patch">Download 0001-added-chdir-and-CWD.patch</a>
<span class="downloadcontenttype">
[text/plain 2k]
</span>
</div>
<div class="messagebody">
<div class="message-stanza-depth-0">
From 17585fed1a5b868be0d8ec0ed9ca84159217d617 Mon Sep 17 00:00:00 2001<br />
From: CosmicNet &lt;webmaster <!-- x --> at cosmicperl.com&gt;<br />
Date: Sun, 19 Apr 2009 16:54:14 +0100<br />
Subject: [PATCH] added chdir and CWD<br />
<br />
---<br />
src/builtins/globals.pir | 8 +++++++<br />
src/builtins/io.pir | 48 ++++++++++++++++++++++++++++++++++++++++++++++<br />
2 files changed, 56 insertions&#40;+&#41;, 0 deletions&#40;-&#41;<br />
<br />
diff --git a/src/builtins/globals.pir b/src/builtins/globals.pir<br />
index 4d51c94..2749127 100644<br />
--- a/src/builtins/globals.pir<br />
+++ b/src/builtins/globals.pir<br />
@@ -53,6 +53,14 @@ src/builtins/globals.pir - initialize miscellaneous global variables<br />
$P0 = info<br />
set_hll_global &#39;$EXECUTABLE_NAME&#39;, $P0<br />
<br />
+ ## create basic $*CWD probably wants changing in future<br />
+ .local pmc os<br />
+ os = new [&#39;OS&#39;]<br />
+ ## Wouldn&#39;t let me use basic string<br />
+ $P0 = new &#39;Str&#39;<br />
+ $P0 = os.&#34;cwd&#34;&#40;&#41;<br />
+ set_hll_global &#39;$CWD&#39;, $P0<br />
+<br />
<div class="message-stanza-depth-1">
## create $*IN, $*OUT, $*ERR filehandles<br />
</div>
.local pmc pio, perl6io, perl6ioclass<br />
perl6ioclass = get_hll_global &#34;IO&#34;<br />
diff --git a/src/builtins/io.pir b/src/builtins/io.pir<br />
index 89bf441..57a98e5 100644<br />
--- a/src/builtins/io.pir<br />
+++ b/src/builtins/io.pir<br />
@@ -167,6 +167,54 @@ Shows the supplied message and then waits for input from $*IN.<br />
.return &#40;$S0&#41;<br />
.end<br />
<br />
+<br />
+=item chdir STRING<br />
+<br />
+Changes the current working directory.<br />
+<br />
+ chdir &#39;/new/dir&#39;;<br />
+<br />
+On Success the value of the new directory is put in $*CWD.<br />
+<br />
+=cut<br />
+<br />
+.sub &#39;chdir&#39;<br />
+ .param string newdir<br />
+ .local pmc os<br />
+ .local int success<br />
+<br />
+ # Error with no arguments.<br />
+ $I0 = length newdir<br />
+ if $I0 goto ok<br />
+ &#39;die&#39;&#40;&#34;Cannot call chdir without an argument&#34;&#41;<br />
+ ok:<br />
+<br />
+ os = new &#39;OS&#39;<br />
+ success = 0<br />
+<br />
+ # Get CWD<br />
+ $S0 = os.&#39;cwd&#39;&#40;&#41;<br />
+ <br />
+ # skip if already there<br />
+ if $S0 == newdir goto noneed<br />
+<br />
+ # Try to set CWD<br />
+ os.&#39;chdir&#39;&#40;newdir&#41;<br />
+ <br />
+ # See if CWD has changed<br />
+ $S1 = os.&#39;cwd&#39;&#40;&#41;<br />
+ if $S0 == $S1 goto finish<br />
+<br />
+ $P0 = new &#39;Str&#39;<br />
+ $P0 = $S1<br />
+ set_hll_global &#39;$CWD&#39;, $P0<br />
+ noneed:<br />
+ inc success<br />
+ finish:<br />
+<br />
+ .return &#40;success&#41;<br />
+.end<br />
+<br />
=back<br />
<br />
=cut<br />
-- <br />
1.6.2.2.1669.g7eaf8<br />
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="ticket-transaction other even">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td rowspan="2" valign="top" class="type">
<a name="txn-553854" href="/rt3/Ticket/Display.html?id=64854#txn-553854">#</a>
&nbsp;
</td>
<td class="date">Sun&nbsp;Apr&nbsp;19&nbsp;10:11:24&nbsp;2009</td>
<td class="description">
RT_System - Tag Patch added
</td>
<td class="time-taken"></td>
<td class="actions">&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="content">
</td>
</tr>
</table>
</div>
<div class="ticket-transaction message odd">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td rowspan="2" valign="top" class="type">
<a name="txn-580452" href="/rt3/Ticket/Display.html?id=64854#txn-580452">#</a>
&nbsp;
</td>
<td class="date">Tue&nbsp;Jun&nbsp;30&nbsp;06:39:42&nbsp;2009</td>
<td class="description">
jnthn <!-- x --> at jnthn.net - Correspondence added
</td>
<td class="time-taken"></td>
<td class="actions">&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="content">
<table>
<tr>
<td align="right" class="message-header-key">RT-Send-CC:</td>
<td class="message-header-value">perl6-compiler <!-- x --> at perl.org</td>
</tr>
</table>
<div class="downloadattachment">
<a href="/rt3/Ticket/Attachment/580452/275780/">Download &#40;untitled&#41;</a>
<span class="downloadcontenttype">
[text/plain 788b]
</span>
</div>
<div class="messagebody">
<div class="message-stanza-depth-0">
On Sun Apr 19 10:11:22 2009, cosmicnetworks wrote:<br />
<div class="message-stanza-depth-1">
&gt; Please find the patch attached. Let me know if you have any questions.<br />
&gt; <br />
&gt; I&#39;ve tested this code against the chdir and cwd spec tests.<br />
&gt; <br />
</div>
I fixed a nit in the $*CWD implementation and applied that one. The test<br />
file all passed, so added that to spectest.data.<br />
<br />
I did some fairly substantial changes to chdir before applying that,<br />
since it didn&#39;t follow the spec as far as error handling went &#40;or at<br />
least, didn&#39;t appreciate the behavior of Parrot&#39;s OS PMC in the way it<br />
did the error handling stuff&#41; and $*CWD was getting set wrongly when<br />
doing a relative change of directory. I also improved the chdir.t to<br />
better test these things, and also added that to spectest.data as well.<br />
<br />
All pushed as git 1317e53.<br />
<br />
Many thanks!<br />
<br />
Jonathan<br />
</div>
</div>
</td>
</tr>
</table>
</div>
<div class="ticket-transaction basics even">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td rowspan="2" valign="top" class="type">
<a name="txn-580456" href="/rt3/Ticket/Display.html?id=64854#txn-580456">#</a>
&nbsp;
</td>
<td class="date">Tue&nbsp;Jun&nbsp;30&nbsp;06:39:44&nbsp;2009</td>
<td class="description">
RT_System - Status changed from &#39;new&#39; to &#39;open&#39;
</td>
<td class="time-taken"></td>
<td class="actions">&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="content">
</td>
</tr>
</table>
</div>
<div class="ticket-transaction basics odd">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td rowspan="2" valign="top" class="type">
<a name="txn-580460" href="/rt3/Ticket/Display.html?id=64854#txn-580460">#</a>
&nbsp;
</td>
<td class="date">Tue&nbsp;Jun&nbsp;30&nbsp;06:39:44&nbsp;2009</td>
<td class="description">
jnthn <!-- x --> at jnthn.net - Status changed from &#39;open&#39; to &#39;resolved&#39;
</td>
<td class="time-taken"></td>
<td class="actions">&nbsp;</td>
</tr>
<tr>
<td colspan="4" class="content">
</td>
</tr>
</table>
</div>
</div>
<hr class="clear" />
</div>
</div>
</div>
<hr size=0>
<div>
For issues related to this RT instance (aka "perlbug"), please contact <tt>perlbug-admin at perl.org</tt>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-50555-18");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<div id="footer">
<p id="time">
<span>Time to display: 1.350304</span>
</p>
<p id="bpscredits">
<span>
&#187;&#124;&#171; RT 3.6.HEAD Copyright 1996-2006 <a href="http://www.bestpractical.com?rt=3.6.HEAD">Best Practical Solutions, LLC</a>.
</span>
</p>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.